Javascript examples for DOM HTML Element:Input Checkbox
Input Checkbox required Property - Set a checkbox to be a required part of form submission:
<!DOCTYPE html> <html> <body> <form action="#"> Checkbox: <input type="checkbox" id="myCheck" name="test"> <input type="submit"> </form>// w w w . jav a2s. co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myCheck").required = true; document.getElementById("demo").innerHTML = "required field."; } </script> </body> </html>