Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Can't copy and paste into textarea

Form doesn't like invisable characters.



3:31 am on Jun 22, 2007 (gmt 0)

10+ Year Member

The textarea in my form doesn't like some of the invisable characters that some word processing programs insert into documents.

When the form is processed, and a preview is shown, the textarea part is blank (as though nothing was entered into it).

As long as visitors type into this box it's not a problem, but there are times when a copy and paste is so much easier for them.

I've noticed this problem when trying to copy .wps files and another that I cannot remember. (Notepad is never a problem.)

Is there a fix for this or maybe a work around that I can suggest to visitors?

Also, I wasn't sure if a fix is possible if it's php related or just a normal form issue.



6:37 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Is it a plain text box or a WYSIWYG?


2:10 am on Jun 23, 2007 (gmt 0)

10+ Year Member

It's just a plain text box. The preview of the form is echoed with HTMLSpecialChars.


8:25 am on Jun 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Is it a browser specific issue or does it fail right across the board?


2:16 pm on Jun 24, 2007 (gmt 0)

10+ Year Member

Not a browser problem.

After some more testing, I have it boiled down to the apostrophe, so it's not even a hidden character, as I had thought.

Copying from an email also causes the text to disappear when there is an apostophe in the text.

Apostrophe's are not an issue when text is typed directly into the form.

When I copy something, is the apostrophe being converted to something that my form can't handle?


3:55 pm on Jun 24, 2007 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

While it's true that "a rose is a rose is a rose", the same cannot be said for apostrophes.

Normal keyboard typing usually just creates ASCII characters -- a straight up-and-down apostrophe, for example. But when you copy/paste, you may be copying a character that is not a "true" apostrophe or single quote, but rather an extended character, such as a right-single quote. This is a curly version or "smart" version of an apostrophe -- such as the characters used in word processing applications and typesetting. See this Wikipedia page [en.wikipedia.org] for more.

Depending on what kind of server processing is going on for form input, this extended character may not be well accomomdated.


6:56 pm on Jun 24, 2007 (gmt 0)

10+ Year Member

For others looking for solutions, do searches for "smart quotes" or "smart apostrophes". You'll find solutions in one form or another.

Thanks guys for guiding me in the right direction.


10:01 pm on Jun 24, 2007 (gmt 0)

5+ Year Member

Do you have a Content-Type meta tag to declare a client-side char-set?


<meta http-equiv="Content-Type"  
content="text/html; charset=iso-8859-1">


1:46 pm on Jun 25, 2007 (gmt 0)

5+ Year Member

i have found a copy paste work-a-round that has helped me a ton when going back and forth between different programs and browsers.

copy from one program.
paste into Notepad (i always keep a shortcut next to my start button)
then highlight all and copy all
then paste into where you want it to go.

give it a shot. this may work for you. if it doesn't I'd like to know so i can keep track of this and find out what does work.


3:14 pm on Jun 25, 2007 (gmt 0)

10+ Year Member

lavazza, yes I do have the content-type meta tag set.

Copying into Notepad does not work for me.

It would be a easy alternative if it did, for me, but it's not a good solution for my site's visitors.

I need to keep things as simple as possible for them and asking them to do something before they actually fill out a form is too much.

Besides the extra work for a visitor, I think it would also reflect a poorer quality of the site.

I'll be testing some code to clean the text up as it is submitted through the form.


7:27 pm on Jun 25, 2007 (gmt 0)

5+ Year Member

Maybe this will help

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html lang="en-GB">

<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<script type="text/javascript">

var myMessage01 ='\nPlease type or paste something into the \'Input\' box\n\n';

function clearFields()

function cleanseUserInput(theInputField)

var theInput = document.myFormName.theInput.value;
var encodedString = '';

if (theInput == '')
var regLength = theInput.length;
//alert('regLength is ' + regLength);
for (i = 0; i < regLength; i++)

//var charCode = '000';
var curChar = (theInput.charAt(i));
if (curChar == '“'){ curChar = '"'; }

if (curChar == '”'){ curChar = '"'; }
if (curChar == '<'){curChar = '&lt;'; }
if (curChar == '>'){curChar = '&gt;'; }
encodedString += curChar;

document.myFormName.encodedString.value = encodedString;

<title>convert curly quotes

<body onload="clearFields();">

<h1> convert “curly quotes” to "straight quotes"</h1>

<form name="myFormName" id="myFormName" action="#" method="post">

This is some text with 'wrong' characters that you can copy and paste into the 'input box' to test that it works

&lt; “abcdefg” &gt;
<h3> user input </h3>
<textarea name="theInput"

<input class="myButtonClass"
value="&nbsp; Go &nbsp;"
<h3> 'cleansed' output </h3>
<textarea name="encodedString"
<input class="myButtonClass"
value=" &nbsp;reset &nbsp;"
onclick="clearFields(theInput, encodedString);"/>


Javascript must be enabled in your browser



[edited by: tedster at 1:45 am (utc) on June 26, 2007]
[edit reason] member request - missing spaces fixed [/edit]


7:44 pm on Jun 25, 2007 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You can try adding an
attribute on the

<form action="/pat/to/script.php" [b]accept-charset="ISO-8859-1"[/b]>

According to this thread [webmasterworld.com] you should try defining the charset of the page via a HTTP header.

Ideally, using UTF-8 rather than ISO-8859-1 is a better choice, as the "curly quotes" and other characters exist in UTF-8.

Also see the thread: UTF-8, ISO-8859-1, PHP and XHTML [webmasterworld.com]. :)


Featured Threads

Hot Threads This Week

Hot Threads This Month