Reputation: 13
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 [email protected] is rejected but the mail [email protected] is acceptable.
what should i change?
Upvotes: 1
Views: 4864
Reputation: 1536
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);
}
Upvotes: 0
Reputation: 618
you might also find http://gskinner.com/RegExr/ useful for creating regexp solutions to stuff like this
Upvotes: 1
Reputation: 7294
var emailExpression:RegExp = /^[\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
BTW, did you try this?
Upvotes: 3