I wonder how I can confirm the email is having a @ sign using javascript before submitting to signUp.php?
<form action='signUp.php'>
<input type='text' name='email'>
<input type='text' name='firstName'>
<button value='submit'>
</form>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use this
javascript:in your form:
I’d better prefer to use something like following:
HTML:
Javascript:
^[a-zA-Z0-9._%+-]+@[A-Z0-9.-]+\.(?:[a-zA-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum|travel)$is a regular expression that checks is a value is a valid email address string. In your question you’ve asked just to test an existence of@in your string, but, hey!not@emailwill be matched! You certainly don’t want to allow strings like that to be treated as valid email strings.Basicly, you want to check your form data before form submit action. So you can do either:
<form onsubmit='if (!checkform()) reutrn;'>or
<input type='submit' onclick='checkform()' />In
checkformfunction you validate fields data and if validation is passed, you callsubmitmethod on html form object and you returnfalseor nothing (e.g.return;) otherwise.You should also learn how to use
regular expressionswithinjavascripthere