I have to valid email address in JavaScript. My method is
function validateEmail(email)
{
var re = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
return re.test(email);
}
Issue is that Visual Studio is not accepting the Regular Expression and giving error when i run the application. The error is
Try escaping @
. @@
will render as @
function validateEmail(email)
{
var re = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
return re.test(email);
}
试试这个正则表达式:
^\w+([.]\w+)*@\w+([.]\w+)+$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.