0

I have the following <input> form element:

<input id="serviceCode" name="serviceCode" type="text" placeholder="" class="form-control input-md" required="" maxlength="4" value="T2" disabled="">

It's strange but this does not come back to the server as a $_POST['serviceCode'] variable. Am I missing something or are "disabled" input form elements not passed back to the server?

H. Ferrence
  • 7,906
  • 31
  • 98
  • 161

2 Answers2

1

Disabled elements are not posted to the server as per the spec :

... it cannot receive user input nor will its value be submitted with the form.

If you wanted to access these values, you might consider making the element readonly or storing the value in a hidden element and using another disabled element to display it.

Rion Williams
  • 74,820
  • 37
  • 200
  • 327
0

Yeah, that's right.

Disabled form elements are not send when the form is submitted.

http://www.w3.org/TR/html5/forms.html#attr-fe-disabled:

The disabled attribute is used to make the control non-interactive and to prevent its value from being submitted.” If you don’t want the user to be able to change the values, but still send them with the form when it is submitted – use the readonly attribute instead.

Aparna
  • 255
  • 1
  • 8