PCHomepage
Programmer
I am a back-end programmer so don't know JavaScript very well other than the very basics so I am unsure how to add a feature to some existing code. The form has a number of field verifications to be sure that everything is filled but I also want to add a final message where selecting OK will allow the form to submit. What I am unsure of is how to do it so that it pops up only after everything else has been properly filled.
Below is the JavaScript it is now and it is also calling other custom functions for the specific "reason" messages. Any ideas?
Here is an example of one of the other functions:
Below is the JavaScript it is now and it is also calling other custom functions for the specific "reason" messages. Any ideas?
JavaScript:
function validateFormOnSubmit(theForm) {
var reason = "";
reason += validateName(theForm.Name);
reason += validatePrefix(theForm.Prefix);
reason += validateTelephone(theForm.Telephone);
reason += validateEmail(theForm.EMail);
reason += validateAddress(theForm.Address);
reason += validateCity(theForm.City);
reason += validateState(theForm.State);
reason += validateCaptcha(theForm.VerifyCode);
if (reason != "") {
alert("Some fields need correction:\n\n" + reason);
return false;
}
return true;
}
Here is an example of one of the other functions:
JavaScript:
function validateName(fld) {
var error = "";
if (fld.value.length == 0) {
fld.style.background = 'Yellow';
error = "Please enter your first and last name.\n";
} else {
fld.style.background = 'White';
}
return error;
}