15
rated 0 times
[
17]
[
2]
/ answers: 1 / hits: 25033
/ 8 Years ago, wed, july 27, 2016, 12:00:00
The relevant part of the code is shown below. When I click the Submit button, on the alert box, I get undefined, rather than the typed email. What mistake am I doing here?
<form action=page2.php method=post onsubmit=myFunction() id=form1>
......
<input type=text name=YourEMail style=width: 250px;>
<input type=submit name=submit value=Submit> <br>
......
</form>
<script>
$('#form1').submit(function() {
//your validation rules here
var email = $('#YourEMail').val()
alert(email)
//if(email.length == 0)
return false;
//else
// return true;
});
</script>
More From » php