Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2003, 09:08 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default Date Validation

Hello everybody how all are fine. I have a problem in validating the Date Entered by the user in the TEXT FIELD, how can I check that user entered a valid date or not.
Please help me in this regard.
Bye

Zaeem Sherazi
__________________
Zaeem Sherazi
 
Old November 5th, 2003, 08:36 PM
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would use three pull downs one for month, one for day, and one for year. I would use javascript to change the number of days in the pulldown based on which month and year was chosen.
Quote:
quote:Originally posted by zaeem
 Hello everybody how all are fine. I have a problem in validating the Date Entered by the user in the TEXT FIELD, how can I check that user entered a valid date or not.
Please help me in this regard.
Bye

Zaeem Sherazi
 
Old November 6th, 2003, 12:15 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default

Thanx for ur reply. I am also using three drop downs (one for day,other for Month,nd the last one for year) and I concatenate three drop down. Now it is time for validation. Now how you can validate this concatenated date?
I am waiting for ur mail.

Zaeem Sherazi
 
Old November 6th, 2003, 12:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

after concatinating the dates seperated by / or other valid seperator you can use isDate()

if isDate(thisDate) then

end iif

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old November 6th, 2003, 12:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

after concatinating the dates seperated by / or other valid seperator you can use isDate()

if isDate(thisDate) then
'Date is valid code
else
'date is not valid code
end if

However by using the dropdowns as vivalet suggested you should not be able to get an invalid date, just add a little js code to ensure that a month with 30 days does not allow 31 to be selected from the day list.


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old October 25th, 2004, 05:33 AM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Cute Designer
Default

u Can use the SimpleDateFormat for that, to validate the format of the date and if it was a valid date too. I did it and if you want my code just tell me ^_^

Cuty
 
Old October 25th, 2004, 06:28 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Cuty

SimpleDateFormat, is that vbscript?

zaeem

I personaly use a pop up calendar:
1..User clicks on a calendar image
2..Selects a date from a 'proper' calendar
3..Onclick it inserts the date into a text area and closes the calendar window.

This way you can not possibly get an invalid date. I also place onFocus and onClick events to make it impossible for the user to type dates manualy. If you use the three drop downs you have to include code to account for:

Edited : Sorry, I just realized Rod had mentioned this

Lets say I pick September. We all know there are 30 days in this month, are you going to detect the month chosen and reload the page to remove 31 off the day selections?

Wind is your friend
Matt
 
Old October 25th, 2004, 11:54 PM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Cute Designer
Default

aha You can Use that .. But I am using JAVA and did that woith SimpleFormat and it works ^_^

Cuty





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Validation aftabn10 PHP How-To 0 January 29th, 2007 10:35 AM
Date Validation ramesh055 ASP.NET 1.0 and 1.1 Professional 1 November 15th, 2006 11:09 AM
date validation (again) crmpicco Javascript How-To 14 March 29th, 2006 06:58 PM
Date Validation surendran Javascript How-To 3 February 25th, 2005 07:40 AM
Date validation Raul Javascript 4 February 25th, 2004 04:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.