dafyddgj dafyddgj - 8 months ago 78
Javascript Question

Calling multiple Javascript functions onSubmit

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();">

Answer Source

You aren't returning anything in allValidation so that it will continue to next method execution. Try this,

function allValidation()
    return validateForm() && selectCountry() && validateEmail();