Check user email address forms to make sure they are valid using JavaScript before saving their info. The JavaScript code is provided here.
The function below checks if the content has the general syntax of an email.
This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign:
<script language="Javascript"> function checksubmit() { apos=document.add_data.email.value.indexOf("@") dotpos=document.add_data.email.value.lastIndexOf(".") if (document.add_data.email.value == "" || apos<1 || dotpos-apos<2) { alert("Please fix: email") document.add_data.email.focus() return false } return true } </script>
Please rate this post by clicking a star:



(6 votes, average: 3.83 out of 5)
cool
Excellent idea and implementation!
Thank you!
if i insert “@.” in my email field then what happens.
I found it will validate this email address.
please give me a proper solution
function isValidEmail(sText) {
var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
return reEmail.test(sText);
}
Blakes function works, but I noticed that if the string contains a long word after the @-sign, the script uses a lot of processor power. This often causes Firefox (3.5.8) or Internet Explorer (7.0) to crash. Test with this string “jfhskdj@jdhrwueyrroqyweuyrs.s”