Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Checkboxes in HTML

What input attribute do I use to make sure the user does not select everything in a list of html checkboxes? For example, I have created five checkboxes, but I want users to only select a maximum of three. I don’t want to use radio buttons in this case. Please keep solutions to only HTML, not javascript.

Thanks. First newbie question here.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

HTML does not have any validation feature that makes that kind of check possible.

You need to use JavaScript to achieve this client-side.

You can use the setCustomValidity method with your custom rules to generate an error message that uses the same style as the native HTML validation messages.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading