Limit number of checkbox selections using javascript

This tutorial shows how to limit the number of checkbox selections in a group of checkboxes. Suppose you have a group fo checkboxes in a form or in a div or table cell or wherever else and you need a requirement that a user can select maximum of two or three or n number of checkboxes then you need to restrict it using javascript or jquery. The below example shows how to achieve it.

Using form example. The below example shows that maximum of two checkboxes can be selected.




Using div example. You can place checkboxes in any tag using attribute id. The below example shows that only one checkbox can be selected.





Thanks for your reading. Please leave a comment if you have any query.


Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.