Submit a Disabled HTML Form Field Value

By default, the HTML 4 specification does not allow disabled form control values to be submitted with other values in a form. Sometimes you want to submit the value from a disabled control like a text box, though, and here I demonstrate an approach to submitting a disabled form control value using a hidden form control. This allows you to display the disabled read-only control while submitting the value contained in the hidden control.

Example

The example simply uses the same value in both the disabled and hidden controls. When the form submits its data, the hidden control’s value will be submitted even as the disabled control’s value is not submitted. Just make sure to use the correct ID/name for the hidden input control so you can process the form data.

[sourcecode language=”html”] <input id="accountnamedisplay" name="accountnamedisplay" class="text" value="SomeValue" disabled="disabled" />
<input id="accountname" name="accountname" type="hidden" class="text" value="SomeValue" />
[/sourcecode]

References

In this example, the INPUT element is disabled. Therefore, it cannot receive user input nor will its value be submitted with the form. Check out the HTML 4 specification for this at http://www.w3.org/TR/html4/interact/forms.html#h-17.12.

Comments are closed.

Sign in
classic
Forgot password?
×
Sign up

(*) Required fields

I agree with OptimaSales Terms & Privacy Policy

×