how to determine if a date is valid

# Thread: how to determine if a date is valid

1. Senior Member
Join Date
Dec 1969
Posts
113

## how to determine if a date is valid

Waht is the best wayt o determine if a date entered is a valid date. byt his I mean if someone enters 2/29/1999 then that is an invalid date and so is 6/31/1960. any help would be greatly appreciated as I don&#039;t know where to start.<BR><BR>Thanks,<BR><BR>Bill

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: how to determine if a date is valid

Define "valid".<BR><BR>30 days has september, april, june and november. All the rest have 31 except February which has 28 days clear and 29 in each leap year<BR><BR>So... Surely just extract the different sections, parseInt() the numbers, and validate that they don&#039;t exceed what the rhyme states.<BR><BR>Craig.

3. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## I like to use my..

.. knuckles instead to remember the numbers of days in the month.<BR><BR>:-D

4. Senior Member
Join Date
Dec 1969
Posts
113

## RE: I like to use my..

Ok, I am trying to figure this out and I would like to parse the string using JavaScript. Can you tell me what the easiest way to do this is. <BR><BR>Thanks,<BR><BR>Bill

5. God
Senior Member
Join Date
Dec 1969
Posts
18,177

There are bajillions of examples out there.<BR><BR>And, I think Bill W has even posted some on here...

6. Senior Member
Join Date
Dec 1969
Posts
11,334

## Check the month

var d = &#039;06/30/1960&#039;;<BR> var dt = new Date(d);<BR> <BR> if (dt.getMonth() == d.substr(0,2))<BR><BR><BR>or something like that. If you use 6/31, dt will contain 7/1.<BR><BR>Work at it man!

7. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Here's one of Bill's..

.. code:<BR><BR>http://www.aspmessageboard.com/forum/showMessage.asp?F=29&M=573279&P=1

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•