Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 18
Viewed: 2997
Added: Nov 23, 2001
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

makes sure some one typed in a valid date in the field

<!---Head--->
<SCRIPT LANGUAGE="JavaScript">
function y2k(number) {
return (number < 1000) ? number + 1900 : number;
}
var reason = '';

function isValidDate (myDate,sep) {
// checks if date passed is in valid dd/mm/yyyy format
if (myDate.length == 10) {
if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep) {
var date = myDate.substring(0,2);
var Month = myDate.substring(3,5);
var Year = myDate.substring(6,10);
var test = New Date(Year,Month-1,date);
if (Year == y2k(test.getYear()) && (Month-1 == test.getMonth()) && (date == test.getDate())) {
reason = '';
return True;
}
else {
reason = 'valid Format but an invalid date';
return False;
}
}
else {
reason = 'invalid spearators';
return False;
}
}
else {
reason = 'invalid length';
return False;
}
}
function tellMeIfInvalid(myDate) {
if (isValidDate(myDate,'/'))
document.write(myDate + ' = valid date<BR>');
else
document.write(myDate + ' = ' + reason + '<BR>');
}
tellMeIfInvalid('21/02/1999');
tellMeIfInvalid('2190291999');
tellMeIfInvalid('2/02/1999');
tellMeIfInvalid('21/2/1999');
tellMeIfInvalid('21/02/199');
tellMeIfInvalid('32/02/1999');
tellMeIfInvalid('21/02/1999');
//-->
</SCRIPT>

<!---Body--->


 none


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions