Jerry,
Here's one I wrote earlier, hope it helps:
function CheckIsNumber(objCheck) {
var strStartFormat = ".+-0123456789";
var strNumberFormat = ".0123456789";
var strCheckChar;
var blnDecimal = false;
var blnDigits = false;
if (objCheck.length == 0)
return true;
strCheckChar = strStartFormat.indexOf(objCheck.charAt(0))
if (strCheckChar == 0)
blnDecimal = true;
else if (strCheckChar < 0)
return false;
for (var i = 1; i < objCheck.length; i++) {
strCheckChar = strNumberFormat.indexOf(objCheck.charAt(i))
if (strCheckChar < 0)
return false;
else if (strCheckChar == 0) {
if (blnDecimal) // Second decimal.
return false;
else
blnDecimal = true; }
else
blnDigits = true; }
return true;
}
If you need to go one stage further to integer add this one:
function tmo_IsInteger(objCheck) {
var strDecimalFormat = ".";
var strCheckChar;
if (objCheck.length == 0)
return true;
strCheckChar = objCheck.indexOf(strDecimalFormat)
if (strCheckChar < 1)
return CheckIsNumber(objCheck);
else
return false;
}
Try that.
Gary
-----Original Message-----
From: Jerry Staple [mailto:[EMAIL PROTECTED]]
Sent: 03 July 2001 09:39
To: CF-Talk
Subject: Data Validation
Hi,
Could someone inform me the best Javascript fucntion to check the value
of a textbox and to make sure the value entered is a number.
Much Apreciated
Jerry Staple
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists