Validating Check Boxes


if (!f.elements["terms"].checked) {   window.alert("Terms & conditions must be Âaccepted!");   f.elements["terms"].focus();   return false; } else {   return true; } 

When a check box has to be filled out, its checked property must be TRue; otherwise, the form should not be allowed to be submitted. The preceding code, available in a full listing in the file mandatory-checkbox.html, demonstrates which code could be called when the submit event of the form is fired.




JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net