valueattribute is used and displayed differently depending on the type of form control to which it’s applied, as detailed below:
The text stated in the
valuewill appear inside the
formcontrol and may be overtyped, copied, or cut by the user. Note that if it’s displayed in the password field, it will be obfuscated, but the correct number of characters will appear nonetheless.
valuewon’t be displayed to the user, nor can it be changed, but it will be associated with the control, and it’s the
valuethat’s passed on when the
Note that the properties chart doesn’t show the
value attribute as being required for all input
types, but in the case of radio and checkbox input types,
value is required.
This code sets a predefined
"Enter search phrase"
for a text input:
<input type="text" name="search" value="Enter search phrase"/>
This attribute can take any name or value of the developer’s choosing.
It causes no compatibility issues, and has excellent support across all tested browsers.
- Wed, 04 Jun 2008 09:30:29 GMT
Digging around for this, I found some other people who have found the same problem. This page has some useful additional ifo:
Jukka Korpela writes:
"VALUE attribute, despite being syntactically valid, has no logical meaning in this context - note that it does not get transmitted in the form data set; but since some browsers use it, instead of ALT, for the alternative text, it is a good idea to include it too (with the same value as ALT)"
- Wed, 04 Jun 2008 08:50:05 GMT
Oh dear. Author commenting on his own work!
I had a bug to fix today at work - a form was not submitting properly in IE and Opera. Looking at the server-side script, it was looking for a value of the submit button. However, the submit button - input type="submit" - had since been changed to an image - input type="image". The value attribute associated with that input was not being passed through upon submission, causing the server-side script to fail. This effect only occurred on IE (all versions) and Opera (tested in 9.26 only, what I had available).
With that in mind, I believe an extra paragraph stating the problem above needs to be added to the section about image type inputs, also the supprt matrix should be changed to partial (or buggy) for IE and Opera.