xodroolis
xodroolis

Reputation: 13

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 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

Answers (3)

Eddie
Eddie

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

overbyte
overbyte

Reputation: 618

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

Upvotes: 1

Timofei Davydik
Timofei Davydik

Reputation: 7294

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

BTW, did you try this?

Upvotes: 3

Related Questions