Had some great help yesterday, and have a followup question/problem. Regarding an HTML form, when the user clicks onSubmit=”return outer()”, the function ‘outer’ only returns one of the two functions inside (either checkname or checkpostal). How do I get it to check both functions? Noob question I’m sure, but I want to understand, and not just copy paste from the plethora of forms out there.
var postalconfig = /^\D{1}\d{1}\D{1}\-?\d{1}\D{1}\d{1}$/;
function outer() {
function checkname(f_name) {
if (document.myform.f_name.value == "") {
alert("Enter your First Name");
return false;
} else {
alert("valid First Name");
return true;
}
}
return checkname();
function checkpostal(postal_code) {
if (postalconfig.test(document.myform.postal_code.value)) {
alert("VALID postal");
return true;
} else {
alert("INVALID postal");
return false;
}
}
return checkpostal();
} //end of outer
The HTML:
<form name="myform" action="index.php" onSubmit="return outer();" method="post">
First Name
<input name="f_name" type="text" />
<br />
Telephone
<input name="telephone" type="text" />
<br />
<input name="Submit" type="submit" value="Submit Form" >
</form>
the execution of the function outer() stops whenever your return.
try this single return statement: