JavaScript Phrasebook

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.

Категории