I have coded a simple web form validation script which goes through all the mandatory fields when a users hits the submit button, and produces an alert box telling the user what field is not filled in. However it produces an alert box for each field, individually, which is slightly annoying. Do you know of a script which will produce a dynamic alert box, one tells you to fill in all mandatory fields that are empty, not just one at a time? Thank you in advance.
My code is below
Code:<script type="text/javascript"> function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt); return false; } else {return true} } }function validate_form(thisform) { with (thisform) { var name = "Patient ID box must be filled out to continue!" if (validate_required(patientid, name)==false) {patientid.focus();return false} else if (validate_required(dob, "Date of Birth box must be filled out to continue!")==false) {dob.focus();return false} else if (validate_required(age, "Age box must be filled out to continue!")==false) {age.focus();return false} else if (validate_required(height, "Height box must be filled out to continue!")==false) {height.focus();return false} else if (validate_required(weight, "Weight box must be filled out to continue!")==false) {weight.focus();return false} else if (validate_required(sex, "Check a Sex button to contunue!")==false) {!sex.checked();return false} else if (validate_required(permission, "Choose Permission Yes or No to contunue!")==false) {!permission.checked();return false} } return true; } </script>



Reply With Quote


Bookmarks