I have two forms, first form contains the textbox and second form contains a button. I want to validate the textbox using the button (jquery or javascript) :
<form name="contactus" method="post">
<input name="txtFirstname" id="Firstname" type="text" class="field" Value="First name*" style="width:300px" />
</form>
<form name="frm1" action="sendemail.php" method="post">
<input id="send" type="image" src="images/sub.png" alt="Submit" style="float:right" />
</form>
how would i be able to do this when my textbox is not on ‘frm1’
Here are examples of the two approaches I suggested in the comments above:
1) Using Javascript to alter the action attribute of the form depending on the button that was clicked:
2) Holding all the submit handler code in a single script (recommended):
HTML:
PHP: