Return to Snippet

Revision: 38512
at January 4, 2011 11:56 by Activetuts


Initial Code
public function checkPhoneNumber(phoneNumber:String):Boolean
{
    var countryCode:String  = "((\\+|00)?([1-9]|[1-9][0-9]|[1-9][0-9]{2}))";
    var num:String      = "([0-9]{3,10})";
    phoneNumber = phoneNumber.match(/[\+\d]/g).join('');
    var phone:RegExp = new RegExp("^" + countryCode + num +"$");
 
    return phone.test(phoneNumber);
}

Initial URL
http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/

Initial Description
From the tutorial, Validating Various Input Data in Flash (http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/)

Initial Title
Validate a Phone Number with RegExp

Initial Tags
phone, number, regexp, validation

Initial Language
ActionScript 3