[thelist] validating date strings with javascript

Tom Dell'Aringa pixelmech at yahoo.com
Thu Feb 20 13:14:00 CST 2003


So I have the typical date field in a form. It should be entered in
the mm/dd/yyyy format.

I have a function that works - except for one thing. If you enter:

1/12/2003  or  1/1/2003

my function will throw an error because the leading '0' or century
has not been put in (Right now I'm merely stripping extra chars and
counting the numbers, less than 8 - kaput).

I'd like to automatically add in the zeros if they only input one
digit for day or month (or both). The problem is this date only gets
entered in ONE field (not 2 or three) and I cannot change that - so
you get one value just like I typed above (sans slashes if you want
it).

I can't think of a way to do this at all, since the amount of numbers
could be so variable..any suggestions?

Tom

=====
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http://www.pixelmech.com/
var me = tom.pixelmech.webDeveloper();

http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the thelist mailing list