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);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson