Skip navigation

Great little snippet of code for validating an email address and a phone number using ActionScript. I love this little functions you can drop in code and just run with. A link to the post here. I have linked rather than replicate the code as I believe in crediting the original author.



    • Marty McGee
    • Posted October 5, 2008 at 12:26 pm
    • Permalink

    Link to post does not work. Any way to post this little snippet?

  1. Yeah appears to be down, I’ll post the code here that I found in a cache, if the original poster is unhappy about it just let me know and I’ll remove it. Probably just a temporary server problem their end or something like that.

    Email Validation:

    function validateEmail(email:String):Boolean {
    var emailExpression:RegExp = /^[a-z][w.-]+@w[w.-]+.[w.-]*[a-z][a-z]$/i;
    return ! emailExpression.test(email);

    Phone Validation:

    function validatePhone(phone:String):Boolean {
    var emailExpression:RegExp = /^((+d{1,3}(-| )’(‘d)’(-| )’d{1,3})|((’d{2,3})’))(-| )’(d{3,4})(-| )’(d{4})(( x| ext)d{1,5}){0,1}$/i;
    return ! emailExpression.test(phone);

    • T
    • Posted February 22, 2009 at 4:20 am
    • Permalink

    try this:


    I think the function will return ‘true’.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: