Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I validate that a date a user enters in NOT before today?

Status
Not open for further replies.

stuboy

Programmer
Feb 14, 2001
2
GB
I am trying to validate user input in a date field. I want to display a message if they enter a date previous to today. I have looked on numerous sites and can't find anything. Any help will be much appreciated.
 
Well snce the Date object gives you integers when getMonth() etc is called - you face the problem of getting good data input. You need some way of getting the right format inputted or modifying it. Once this is done, you just need an if statement which first comapares the year - then the month then the day - each time asking if it is before the current ones.

Select boxes probably provide the easiest way to ensure data entry, without having to validate all the time - maybe except for the year.
b2 - benbiddington@surf4nix.com
 
thanks for that, I have tried it and it works a treat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top