Inspired and copied from http://simon.incutio.com/code/js/date-parser/ and http://javascript.internet.com/calendars/fuushikaden-pop-up-calendar.html
This I think is a very neat way of inputting dates on a web form. The server side code must thus be able to parse both 13 december 2003
and 13/12/2003
but that shouldn't be too hard with the DateTime
module.
Look at the demo
If you have a browser with which this doesn't work let me know by posting a comment here.
UPDATE this demo had a little bug in the output that I have now fixed.
Comments
Post your own commentHi Peter,
what about i18n? I'm from germany and need to fill in something like '13 März 2004'.
Is this possible?
Greets, Sönke
Not sure. You can translate the strings in the javascript for the dateparse.
For the popup calendar I guess that's the same too.
I.e. search for "Mars" and replace it with "März".
very nice. I notice that If I put my birthdate as 7/8/1969 (US month/date) it interprets it as date/month (7th of august instead of 8th of july) but I like it! Mind if I download the javascript and start using it?
very nice. I notice that If I put my birthdate as 7/8/1969 (US month/date) it interprets it as date/month (7th of august instead of 8th of july) but I like it! Mind if I download the javascript and start using it?
That's because you americans are wrong! No, actually I hacked the original script to do the british style before the american style. See the dateparse.js source and look for comments with 'Peter' in them.
It's not a matter of who is wrong or not. Wrong attitude!
Peter: That javascript seems to be a bit dated, it has bugs that show up once you set a DOCTYPE on the html, something like described here: http://javascript.about.com/library/bliebug.htm
but it's not using document.documentElement or document.body (as mentioned in that article). It works without a DOCTYPE (as in your demo) or with a DOCTYPE for HTML 3.2, but it sets the position of the calendar wrong with any more modern DOCTYPE string in IE, Safari, and Firefox.
Since I'm not a JavaScript dude, I've not attempted to fix things so far.
Hey, and what's up? You're not on #zope any more?
Found an updated version at:
http://www.thalys.com/js/calendar.js?lg=en&country=fr
(Which works fine even with newer browsers using proper DOM.) Calling the popup seems to have a different method signature, and I haven't figured out too much yet, but something like onclick="popUpCalendar(this, this, 'dd-mm-yy','17-04-2001','01-01-2038') seems to work.