How can I make a checkbox readonly? not disabled?

Naga picture Naga · Sep 4, 2012 · Viewed 160.9k times · Source

I have a form where I have to post form values to my action class. In this form I have a checkbox that needs to be readonly. I tried setting disabled="true" but that doesn't work when posting to the action class.

So please advice??

Answer

Kundan Singh Chouhan picture Kundan Singh Chouhan · Sep 4, 2012

There is no property to make the checkbox readonly. But you can try this trick.

<input type="checkbox" onclick="return false" />

DEMO