Valid Email in ActionScript 3

半世苍凉 提交于 2020-01-14 03:34:09

问题


i am using

var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;

for validation check in a contact form in ActionScript3.


The problem is that if the email submitted starts with a numeric character then it is rejected. for example the email 45yah.yah@yahoo.com is rejected but the mail yah45.yah@yahoo.com is acceptable.

what should i change?


回答1:


var emailExpression:RegExp = /^[\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;

BTW, did you try this?




回答2:


you might also find http://gskinner.com/RegExr/ useful for creating regexp solutions to stuff like this




回答3:


Here is one that does not fail with q.com email addresses.

function isValidEmail(email:String):Boolean {
    var emailExpression:RegExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
    return emailExpression.test(email);
}


来源:https://stackoverflow.com/questions/5713603/valid-email-in-actionscript-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!