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;
}

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