Forum Moderators: open
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.
Thanks,
Suzie
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?
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.
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.
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.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-GB">
<head><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()
{
document.myFormName.theInput.value='';
document.myFormName.encodedString.value='';
}function cleanseUserInput(theInputField)
{var theInput = document.myFormName.theInput.value;
var encodedString = '';if (theInput == '')
{
alert(myMessage01);
}
else
{
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 = '<'; }
if (curChar == '>'){curChar = '>'; }
encodedString += curChar;
}document.myFormName.encodedString.value = encodedString;
}
}
//--></script>
<title>convert curly quotes
</title>
</head><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
<br/>
<br/>< “abcdefg” >
<br/>
<h3> user input </h3>
<textarea name="theInput"
rows="1"
cols="60"
id="theInput"></textarea><br/>
<input class="myButtonClass"
type="button"
value=" Go "
onclick="cleanseUserInput(theInput);"/>
<br/>
<br/>
<h3> 'cleansed' output </h3>
<textarea name="encodedString"
rows="2"
cols="60"
id="encodedString"></textarea>
<br/>
<input class="myButtonClass"
type="reset"
value=" reset "
onclick="clearFields(theInput, encodedString);"/></form>
<noscript>
Javascript must be enabled in your browser
</noscript></body>
</html>
[edited by: tedster at 1:45 am (utc) on June 26, 2007]
[edit reason] member request - missing spaces fixed [/edit]
accept-charset attribute on the form element: <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]. :)