Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a checkbox readonly? not disabled?

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??

like image 780
Naga Avatar asked Sep 04 '12 15:09

Naga


People also ask

How do you make a check box read-only?

//This will make all read-only check boxes truly read-only $('input[type="checkbox"][readonly]'). on("click. readonly", function(event){event. preventDefault();}).

How do I make a non clickable checkbox?

Practically speaking, this is the solution that many of us are looking for. How to make the checkbox un-changeable (answer: disable it) but still preserve the value of whether it is checked or not upon save (answer: use a hidden input type). Make sure to only add the hidden input if you have also disabled the checkbox.


1 Answers

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

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

DEMO

like image 110
Kundan Singh Chouhan Avatar answered Sep 19 '22 01:09

Kundan Singh Chouhan