1

Here is my code. How can I make my checkbox readonly mode so that user cannot edit again?

<input type="checkbox" id="tog_gmat"
       <?php 
           if($gmat_flag == 1) 
              {
                echo "checked";
              } 

        ?> 
class="chk" value="GMAT">
gabe3886
  • 4,235
  • 3
  • 27
  • 31
Kavya Shree
  • 1,014
  • 2
  • 17
  • 52
  • 2
    Possible duplicate of [Can HTML checkboxes be set to readonly?](http://stackoverflow.com/questions/155291/can-html-checkboxes-be-set-to-readonly) – Cyclonecode Feb 05 '16 at 11:55

2 Answers2

2

You can add attribute disabled="disabled". But be aware that disabled checkbox does not send value via POST.

Timo
  • 727
  • 5
  • 15
1

Just return false when clicked

<input type="checkbox" onclick="return false" id="tog_gmat" <?php if($gmat_flag == 1){echo "checked";} ?> class="chk" value="GMAT">

Or with jQuery.

$('#tog_gmat').on('click', function() {
    return false;
})

Update

<input type="checkbox" id="tog_gmat" <?php if($gmat_flag == 1){echo "checked onclick='return false'";} ?> class="chk" value="GMAT">
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87