View Full Version : validate a date

10-14-2006, 05:12 PM
i got one text box..is let the user enter the borrow date using a javascript calendar. how to i block the user to enter the date earlier than today date?using the javascript?i mean...if the user enter date that earlier than today...got one alert message....plz help..

10-14-2006, 05:53 PM
what is the format of the date your users are inputting?

10-14-2006, 09:51 PM
Use the date object:

var todayInMillisecond = (new Date()).getTime();
var theirInput = prompt('Gimme a date, man!');
if (todayInMillisecond > Date.parse(theirInput))
alert('Whoa there, time traveller, come on back to the future.');