Submit a HTML form with disabled fields

I have been trying to disable all the fields before submit, so no extra validation will be needed for the edit page.

It is not possible to submit a DISABLED field…

A possible solution is use READONLY attribute, but this is for textfield and textarea ONLY,  but I want all the fields to be un-changeable.

After some research, I summerised the following techniques (hacks):

  1. The first is ugly, it involves using JavaScript on the onsubmit handler to enable all of the disabled fields. Yucky, bit some people perfer this to the next method.
  2. The second is rather easy, change the fields to readOnly instead of diabled. If you want to have the same look as disabled apply some css classes to those elements.
    Looks disabled:
  3. Hidden fields: When you submit the form with the disabled fields, intercept that and  transfer all the entries into the hidden fields, and then submit that.


And guess what, I’ve chosen the ugly approach, #1:

…because it is the simplest working solution~

Leave a Reply

Your email address will not be published. Required fields are marked *