clyde
07-25-2003, 08:33 AM
If I Have The User Enter a Date, Is There a Function to determine if the date is Valid.
Thanks
Clyde
Thanks
Clyde
|
Click to See Complete Forum and Search --> : Date Validation clyde 07-25-2003, 08:33 AM If I Have The User Enter a Date, Is There a Function to determine if the date is Valid. Thanks Clyde AdamBrill 07-25-2003, 08:38 AM If you give me the format that you want the date in, I can write a regex for you.... Do you want it like this? xx/xx/xxxx clyde 07-25-2003, 08:39 AM xx/xx/xxxx is the correct format AdamBrill 07-25-2003, 08:47 AM Ok, try something like this:function validate(){ if(/^\d{2}\/\d{2}\/\d{4}$/i.test(document.formname.inputname.value)){ return true; }else{ return false; } } Khalid Ali 07-25-2003, 08:57 AM Just to add to the answers...above Date object has a parse() method,if the date is parsed its a good format else iits not Here is how it would work user inputs a date var userInput = "07*25*2003"; alert(Date.parse(userInput)) will return NaN var userInput = "07-25-2003"; alert(Date.parse(userInput)) will return result in milliseconds 1059112800000 webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |