I am facing a problem to submit two forms with one JavaScript function.
In that I have called one ajax file to check the username availability.
The forms are as below
<form action="abc.php" method="post" enctype="multipart/form-data" onsubmit="return isValid(this)" class="login_form" style="width:100%;">
<form action="http://example.com" method="post" enctype="multipart/form-data" onsubmit="return isValid(this)" class="login_form" style="width:100%;" name="form1" id="form1">
In isValid() function when I do
alert ("hi");
document.form1.submit();
alert("bye");
Then it submitting the form1 else it does not.
You need to return a boolean value from the
isValid()function since you’re passing that value back to theonsubmitevent of the forms:Something like this should work for what you need: