Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dates in forms

 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic