Search code examples
htmlformsinputdisabled-input

Are "disabled" _POST variable form elements empty Server-Side?


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?


Solution

  • 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.