-2

How to protect user to clear checkbox using javascript ?

I want to protect clear checkbox from user using javascript

(not use disabled tag) How can i do that ?

<input type="checkbox" id="c1" checked> Do not uncheck

1 Answers1

0

Not sure why you'd want a checkbox that can't be unchecked but you can simply do this:

$(".dontUncheck").click(function(e){
   e.preventDefault();
   $(this).prop("checked", "checked");
});

<input type='checkbox' checked  class="dontUncheck" />

Here's the fiddle: http://jsfiddle.net/0x9vp6ca/

Birgit Martinelle
  • 1,869
  • 1
  • 12
  • 9