JavaScript date validation function

Joe Crown joecr at linuxmail.org
Sun Jul 23 23:48:11 MDT 2006


I've worked on a JavaScript function, or more accurately group of 
functions, which takes a date from one field, then checks if it is a 
valid date.  Then if the date is valid it puts it into the field in 
whatever form the web master wants it.  Here are some examples of the 
formats it supports DD\MMMM\YYYY, DD\YYYY\MMMM, MMMM\DD\YYYY, 
MMMM\YYYY\DD, YYYY\DD\MMMM, YYYY\MMMM\DD, DD/MMM/YYYY, DD/YYYY/MMM, 
MMM/DD/YYYY, MMM/YYYY/DD, YYYY/DD/MMM, YYYY/MMM/DD, DD-MM-YYYY, 
DD-YYYY-MM, MM-DD-YYYY, MM-YYYY-DD, YYYY-DD-MM, YYYY-MM-DD, D M YYYY, D 
YYYY M, M D YYYY, M YYYY D, YYYY D M, or YYYY M D.  If the date is not 
valid it gives an error message depending on what kind of mistake was made.

The rules are the year must be a 4 digit year; the year must not be 
before 1562 as it is designed only for dates in the Gregorian calendar 
(http://en.wikipedia.org/wiki/Gregorian_Calendar).  The month can be 
spelled out, abbreviated, numerical, or be numerical with a leading "0". 
  The day is numerical & can have a leading "0".  I have designed it so 
that supporting other languages should be relatively easy.  At the very 
least I'd need translations for the error messages & months, possibly 
addition information would be needed for some languages as I only speak 
American English, remember a tiny bit of Spanish, & am working on 
learning Japanese (I still don't know enough to have a conversation of 
only a few sentences, after that I have no idea what to say in Spanish 
or Japanese).

So I was wondering what you thought I should do with this.  I want it & 
the ideas it uses to spread to other programs if they haven't already. 
I was going to patent the idea, but I have since learned that I can't 
afford the cost of doing that.

I’ve thought of several different projects that might benefit from this, 
but I wanted to get other peoples idea of what I should do with it.  I 
have no idea if I should do it to a certain distribution of Linux, 
Apache, Ruby on rails, or something else.

-- 

American Family Association & 30+ Other Groups Call for Boycott of Ford 
Motor Company
http://www.boycottford.com/

The Electronic Frontier Foundation is highlighting three sets of bad 
laws going through Congress right now.
http://www.eff.org/corrupt

This e-mail is printed on 100% recycled electrons.

Don't pay malware vendors - boycott Sony & Symantec

Joe Crown aka joker

joecr at linuxmail.org

A common mistake that people make when trying to design something 
completely foolproof is to underestimate the ingenuity of complete fools.

Douglas Adams, "Mostly Harmless"


More information about the PLUG mailing list