Here are the two JS functions you are looking for.  I'll assume you know how
to use them :)

--------------------------------------------------------------

function isInteger(str){
        
        if( str.length == 0 )
                return false;
                
        for( i=0; i<str.length; i++ ){
                if( str.charAt(i) < "0" || str.charAt(i) > "9")
                        return false;
        }
        return true;
}


function isDate(str){
        
        if( str.length != 8 )
                return false;
                
        // find the month
        month = str.substring(0,2);
        day = str.substring(3,5);
        year = str.substring(6,8);
        
        // check for integers
        if( !(isInteger(month) && isInteger(day) && isInteger(year)) )
                return false;
        
        // determine how many days are in this month
        maxDay = 31;

        if( month == 4 || month == 6 || month == 9 || month == 11 ) maxDay =
30;
        else if( month == 2 ){
                if( year % 4 > 0 || (year % 100 == 0 && year % 400 > 0) )
maxDay =28;
                else maxDay = 29;
        }
        
        // check ranges
        if( month < 1 || month > 12 )
                return false;
        if( day < 1 || day > maxDay )
                return false;
        
        // if we made it this far it's a good date
        return true;
}
--------------------------------------------------------------------
                                                    
Bryan Love ACP
Internet Application Developer
[EMAIL PROTECTED]
                                                    


-----Original Message-----
From: CF Crazy [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 03, 2001 3:12 PM
To: CF-Talk
Subject: Please Help


I am in desperate need of a simple validation of two types of form fields.

1.   Date field (not a cfform just a plain form) - must validate that data 
entered is a date

2.  Number field (not a cfform just a plain form) - must validate that data 
entered is a number


Thanks

Stephanie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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