开发者

Valid Email in ActionScript 3

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 pro开发者_运维知识库blem 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?


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

BTW, did you try this?


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


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜