How to create a checkbox that cannot be changed (readonly)

Asked

Viewed 57 times

0

I would like to make sure that the checkbox is not changed (readonly).

  • 2

    is that what you need? https://jsfiddle.net/r5wpandw/

  • Post your code. Enjoy and make a tour also to learn more about the site.

  • this @miltoncamara! Thank you so much!

2 answers

3


@Carloshenrique, you can do something like:

<input type="checkbox" checked="checked" disabled> Checkbox

Note that includes the disabled attribute in the input.

Follow an example link: https://jsfiddle.net/r5wpandw/

0

Through Javascript

document.querySelectorAll('input[type="checkbox"]').forEach(
  node => node.onclick = function() {
    return false;
  }
)
<input type="checkbox" name="chk1" id="chk">
<input type="checkbox" name="chk1" id="chk" checked>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.