Page 1 of 1

Can HTML checkboxes be set to non editable?

PostPosted: Thu Mar 14, 2013 1:24 am
by josmy
Yes, it's possible.

There may be situations like where we want to restrict user to change the selected value of a check box, especially on edit form pages,

After doing much googling, i found the following solutions.

Method -1
----------------
Just add disabled="disabled" as attribute.
<input type="checkbox" disabled="disabled" checked="checked">

* The disadvantage is, while submitting this form, server page won't get the value from a disabled control.

Method - 2 - ( feasible method for me)
------------------------------------------------
Just add both [onclick="return false"] and [onkeydown="return false"] attributes.
<input type="checkbox" onclick="return false" onkeydown="return false" checked="checked" />

Thanks friends, hope this would be helpful in your development time.

Re: Can HTML checkboxes be set to non editable?

PostPosted: Thu Mar 14, 2013 6:59 am
by beniston
Yes it is. This will remind a web develop in time of a need like this. Thanks :)