Do not disable checkboxes

To make a checkbox uncheckable, one common mistake is to

<input name="test" type="checkbox" value="1" checked disabled="true">

the disabled checkbox actually makes the checkbox unusable. So if you have some scripts to be triggered after the form is submitted, the checkbox test field will not come in at all. If you don’t want people to mess with the checkbox, making it “readonly” will also not help. One way is to hid it using css.

<input name="test" type="checkbox" value="1" checked style="display:none">

Another way is to use javascript to make it unclickable, ie

jQuery('#your_id').click(function() { return false; });

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.