CFLib.org – Common Function Library Project

isValidPhone(valueIn)

Last updated September 25, 2009

author

Alberto Genty

Version: 3 | Requires: CF5 | Library: StrLib

Description:
Simple Validation for Phone Number syntax.

Return Values:
Returns a boolean.

Example:

<cfoutput>
333-333-3333 - #isValidPhone("333-333-3333")#<br>
333-333-333 - #isValidPhone("333-333-333")#<br>
333-333 - #isValidPhone("333-333")#<br>
333A333 - #isValidPhone("333A3333")#<br>
333-333@3333 - #isValidPhone("333-333@3333")#<br>
</cfoutput>

Parameters:

Name Description Required
valueIn String to check. Yes

Full UDF Source:

/**
 * Simple Validation for Phone Number syntax.
 * version 2 by Ray Camden - added 7 digit support
 * version 3 by Tony Petruzzi Tony_Petruzzi@sheriff.org
 * 
 * @param valueIn      String to check. (Required)
 * @return Returns a boolean. 
 * @author Alberto Genty (agenty@houston.rr.com) 
 * @version 3, September 25, 2009 
 */
function IsValidPhone(valueIn) {
     var re = "^(([0-9]{3}-)|\([0-9]{3}\) ?)?[0-9]{3}-[0-9]{4}$";
     return    ReFindNoCase(re, valueIn);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson