Nice date input

17 October 2003   8 comments   Zope

Powered by Fusion×

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

Sönke
Hi 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
Peter
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".
Anonymous
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?
Jim
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?
Peter
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.
Andreas
It's not a matter of who is wrong or not. Wrong attitude!
Sascha Welter
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?
Sascha Welter
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.
Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
My breakfast 17 October 2003
Next:
Systembolaget under pressure 21 October 2003
Related by keywords:
Date formatting in python or in PostgreSQL 20 July 2004
rfc822() vs. rfc1123_date() 16 August 2007
Date formatting in Python or in PostgreSQL (part II) 19 April 2006