Setting a value to Html form field

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

     I am trying to set a hidden form value.
When the value contains ' the page is giving some unwanted results.
Please let me know, how to handle this

Html code for your reference:
<input type='hidden' name='hiddenValue' vaule='that's it'/>


Re: Setting a value to Html form field

Quoted text here. Click to load it

Pretend you're a computer. Read through your code and ask yourself where
your computer thinks the values for your attributes begin and end.


Re: Setting a value to Html form field

boss wrote:

Quoted text here. Click to load it

This time the fragment is sufficient for analysis, though not for solving
other problems (like "is it really a good idea to use hidden fields in your
case?"). The URL would still have been useful. For example, it often happens
that when you type or copy HTML markup into a message, some nasty software
transmogrifies it so that it isn't exactly the original.

Actually, the attribute name vaule is misspelled in your snippet. Your
actual page probably contains the correct spelling, value.

The problem is that the apostrophe ' is not allowed inside the quoted
attribute value when the apostrophe is used for quoting the string, as a
delimiter. You can avoid the problem in several ways, e.g. using quotation
mark as delimiter:
value="that's it"
or using a character reference,
value='that&#39;s it'
or maybe the typographically correct curly apostrophe (assuming you really
want to include the natural-language expression you gave as example), either
as such (I won't try it here because Usenet is not safe for non-ASCII,
though the web mostly is, properly used) or as a character reference:
value='that&#8217;s it'


Site Timeline