This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
What do you think the best way to handle dates are in HTLM forms? Allowing the user to type in a date, giving them a recommended format and causing an error if they type it in wrong? Have the user select from a three separate list boxes the month, day, and year? Or some other way? Thanks for the help! Brian bcnice@mindspring.com
maha anna
Ranch Hand
Joined: Jan 31, 2000
Posts: 1467
posted
0
Brain, Personally I used mm-dd-yy format or other formats depending upon the need. I am not sure why I don't like those pull downs for each month,day,year selections. I just picked up a nice Java Script code snippet from this URL and used in one of my applications and it is great. Please take a look at it. http://javascript.internet.com/forms/val-date.html regds maha anna [This message has been edited by maha anna (edited January 03, 2001).]
Brian Nice
Ranch Hand
Joined: Nov 02, 2000
Posts: 195
posted
0
Thank you maha anna, that looks very helpful. One question though, since that script allows for several different formats to be accepted, is there an easy way to convert the date string that comes in as a request parameter from the form, into a Date object? For example, if someone types 1/3/01 and another person types 01.03.2001, both are valid. Do you have to use multiple SimpleDateFormat objects and parse through them or do you have some sort of method that parses the string and tries to figure the month, day, year and consruct a Date object from that? Thanks for the help/suggestions! Brian bcnice@mindspring.com
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
I don't think a general solution is possible. Not least because even a human can't reallyt know whether 01/03/01 means the 1st of March (European Style) or 3rd of January (US Style), and that's without even considering which century to use for the year. The best way I have seen of entering dates is to use one of the many pop-up JavaScript calendars.