Thanks Very Much.

Jerry

-----Orig
inal Message-----
From: Alistair Davidson [mailto:[EMAIL PROTECTED]]
Sent: 05 July 2001 09:12
To: CF-Talk
Subject: RE: Data Validation


jerry,

how about parseFloat() or parseInt(), depending on whether you only want
integers?

something like

function check_numeric( obj )
{
        // parseInt() returns NaN (Not a Number)
        // if it can't parse an integer out of the string
        if( isNaN( obj.value.parseInt() ) )
        {
                alert( "That is not a number!" );
                obj.focus();
                return false;
        }
        else
                return true;

}

and your input box can check this onblur (when it loses focus) like so -

<input name="numberbox" type="text" ......
onblur="check_numeric(this);">

or you can check it in the form.onsubmit() -

<form ...... onsubmit="return(check_numeric( numberbox ));">


A good reference for JS (and VBS) functions can be found at
http://msdn.microsoft.com/scripting/default.htm

Hope that helps 

Alistair Davidson
Senior Web Developer
Rocom New Media
http://www.rocomx.net

-----Original Message-----
From: Jerry Staple [mailto:[EMAIL PROTECTED]]
Sent: 05 July 2001 09:07
To: CF-Talk
Subject: Data Validation


Hi,
   Could anyone inform me of the best javascript function to validate a
textbox, so that only a number can be entered.

Many Thanks     
        
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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to