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!

Date Validation

Status
Not open for further replies.

JrClown

Technical User
Oct 18, 2000
393
US

Hello all. Here's my Q.

I have an ASP form with two (2) date fields From: and To: The question is, how can I force all user to type in the correct date? Some user leave the fields blank by accident and it throws an error others type in the dates as 22301 when it should be 2/23/01. How do I go about fixing this? Thanks in advance fellas.
QUOTE OF THE DAY
Don't waste time telling people what you are doing or what you are going to do. Results have a way of informing the world.

<%
Jr Clown :eek:)
%>
 
There has been a lot of date questions in this forum. It is easier to validates dates through ASP than client validation via Javascript simply because JavaScript does not have a reserved function to check for a valid date.

So the easiest way for you might be to use the IsDate() function to check whether a date is valid or not.

Also instead of giving the users a single text box you might want to give them 3 different drop downs which lists the months/days/years and once they do the selection, you can do your own formatting prior to processing it. This way the user will not assume the format.

If you want to stay with the single text box system, you might want to let the users know what format you want him to type in the field, simply by mentioning(mm/dd/yyyy) within brackets right next to the field.

All this is possible via ASP. If you want to do client side validation through Javascript, it is different story all-together. But I can still give you more info on it.

I hope this is helpful.
 

Thanx for your advise Antzz. I've decided to simply hard code the initial value of the fields with MM/DD/YY. Thanks again QUOTE OF THE DAY
Don't waste time telling people what you are doing or what you are going to do. Results have a way of informing the world.

<%
Jr Clown :eek:)
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top