I'm trying to call multiple JavaScript functions. It submits even though my functions return false. I receive the alert messages but it submits anyway.
This is my form.
<form name="myform" id="myform" action="receipt.html" method="post" onSubmit="return allValidation();">
You aren't returning anything in allValidation, so that it will continue to next method execution. Try this,
function allValidation() {
return validateForm() && selectCountry() && validateEmail();
}
You can use multiple functions and then and their results to get final validation. and also add return true statements in all functions where validation is successful
function allValidation()
{
return (validateForm() && selectCountry() && validateEmail());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With