how to POST/Submit an Input Checkbox that is disabled?

AnApprentice picture AnApprentice · Jan 18, 2011 · Viewed 105.9k times · Source

I have a checkbox that, given certain conditions, needs to be disabled. Turns out HTTP doesn't post disabled inputs.

How can I get around that? submitting the input even if it's disabled and keeping the input disabled?

Answer

Francesco Laurita picture Francesco Laurita · Jan 18, 2011

UPDATE: READONLY doesn't work on checkboxes

You could use disabled="disabled" but at this point checkbox's value will not appear into POST values. One of the strategy is to add an hidden field holding checkbox's value within the same form and read value back from that field

Simply change disabled to readonly