checkbox - HTML5 Browser Validation for Checkboxes - given multiple checkboxes how can I make sure at-least one is selected? -
given simple this:
<form ...> <input type="checkbox" required name="op1"> option 1</u> <input type="checkbox" required name="op2"> option 2</u> <input type="submit"> </form>
is there way using html5 validation validate if 1 of boxes checked , if none selected focus required tooltip on form?
you cannot html5 here way javascript
html
<form onsubmit="return checkcheckboxes(this);"> <input type="checkbox" required name="op1"> option 1</u> <input type="checkbox" required name="op2"> option 2</u> <input type="submit"> </form>
javascript
<script type="text/javascript" language="javascript"> <!-- function checkcheckboxes(theform) { if ( theform.opt1.checked == false && theform.opt2.checked == false) { alert ('you didn\'t choose of checkboxes!'); return false; } else { return true; } } //--> </script>
Comments
Post a Comment