CFLib.org – Common Function Library Project

isTrueNumeric(str)

Last updated August 18, 2005

author

Tomas Becklin

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Verifies each characters in a string to be numeric. The existing isNumeric() function accepts e (express scientific notation) and d (denote double precision) as numeric characters and will return true/yes.

Return Values:
Returns a boolean.

Example:

<cfoutput>
isTrueNumeric():<br>
333e3: #isTrueNumeric('333e3')#<br>
333d3: #isTrueNumeric('333d3')#<br>
33333: #isTrueNumeric('33333')#<br><br>
isNumeric():<br>
333e3: #isNumeric('333e3')#<br>
333d3: #isNumeric('333d3')#<br>
33333: #isNumeric('33333')#
</cfoutput>

Parameters:

Name Description Required
str Value to check. Yes

Full UDF Source:

/**
 * Returns true if all characters in a string are numeric.
 * Version 2 by Raymond Camden
 * 
 * @param str 	 Value to check. (Required)
 * @return Returns a boolean. 
 * @author Tomas Becklin (tomasbecklin@gmail.com) 
 * @version 2, August 18, 2005 
 */
function isTrueNumeric(str) {
	return reFind("[^0-9]", str) is 0;
}
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