How can I get the form value from a disabled <input> element
You should use the readOnly
flag rather than disabled
. Read-only fields cannot be edited by the user, but are still submitted with the form.
<input type="text" value="blah" readonly="true"/>
The HTML standard for forms appears to be such that disabled input elements do not contribute to the form name/value collection.
That is correct.
HACK: You could use Javascript to, upon submit:
- Unset disabled
- Set readonly
- Submit!
If you make the value readonly, instead of disabling it, the field's name/value will be sent with the rest of the non-disabled fields.
Make the readonly fields' focus event handler pass the focus to the next eligible field, to make it act more like a disabled element. Some browsers let you focus and select readonly fields, and some even let you paste into a readonly field, though they revert to the original value onblur and onchange.
<input type="text" value="" readonly="readonly">