Expand|Select|Wrap|Line Numbers
- function validateFormOnSubmit(theForm) {
- var reason = "";
- reason += validateEmpty(theForm.from);
- reason += validateUsername(theForm.username);
- reason += validatePassword(theForm.pwd);
- reason += validateEmail(theForm.email);
- reason += validatePhone(theForm.phone);
- if (reason != "") {
- alert("Some fields need correction:\n" + reason);
- return false;
- }
- return true;
- }
- // validate empty fields
- function validateEmpty(fld) {
- var error = "";
- if (fld.value.length == 0) {
- fld.style.background = 'Yellow';
- error = "The required field has not been filled in.\n"
- } else {
- fld.style.background = 'White';
- }
- return error;
- }
But the thing is different pages have different number of fields.(page 1 have 5 text boxes, page 2 have 10 text boxes etc.). So could you please tell me how can I use the same validate file to every page?