I have a javascript function that checks if someone entered their email:
function formValidate(){
form1 = document.forms['_register1'];
if (form1.elements['email'].value == 'Type Your Email Address Here')
{
alert('Please enter your email address.');
form1.elements['email'].focus();
return false;
}
}
Here is the form html:
<form method="post" enctype="multipart/form-data" name="_register1" id="_register" action="signup.php" >
<input type="text" class="field" value="Type Your Email Address Here" name="email" title="Type Your Email Address Here" />
<input type="submit" class="button button-signup" value="SIGN UP!" onclick="formValidate();" />
If the user has not entered an email address, I want the javascript alert to popup and once the user presses ok, I want the page to stay the same. I don't want the action="signup.php" to happen until the email is valid. This seems like it should be simple but I've looked all over the internet and can't find a solution.
Thanks.
I finally figured out the answer. The key is to use the javascript submit() function. Rather than use an input type submit, I use just a regular button. Then, after javascript validates the form and the form has the proper data, I used the submit function. Here is my code below. If anyone is curious, feel free to ask me about it.
And here is the html: