Forum Moderators: phranque

Message Too Old, No Replies

Simple Form Question!

Forcing users to enter the date correctly

         

chowcat

5:31 pm on Sep 12, 2002 (gmt 0)



I am half way through making a booking form, and will be including a date field, however because my client wants all customers to enter the date into the field in the same way (but does not want drop downs) I was thinking that by already having the date format entered in the field: i.e. dd/mm/yyyy we could acomplish it.

Thats simple enough, how can I make the pre entered "format" dissapear when someone booking clicks once into the box. I have seen it done.

Any ideas.

txbakers

6:09 pm on Sep 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onClick="this.value=''" would work

your boss does realize, however, that even though there is a guide, people will still enter the date any which way.

You would have to validate the form value before submitting to make sure it will be in the proper format.

oilman

6:15 pm on Sep 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tx it right. Without validation of form values you're gonna get all manner of date formats. I've given up on taking the whole date in one field - I take it in 3 fields now and put them together in the order I want later. One field for Month, one for Day (both of these are usually drop downs for the user to select and the a year field that is a drop down or a validated 4 digit numeric only field depending on the use and how far back dates may have to go.

chowcat

8:44 am on Sep 13, 2002 (gmt 0)



Thanks, I've mentioned more than once its not going to happen the way he would like it to, but at the end of the day he has to realise that himself.

Thanks.

gsx

2:57 pm on Sep 13, 2002 (gmt 0)

10+ Year Member



Alternatively you can have option boxes on the form that allow the user to select their preferred type of date entry (British dd/mm/yyyy, US mm/dd/yyyy, Text dd mmm yyyy etc...)

chowcat

4:39 pm on Sep 13, 2002 (gmt 0)



could you elaborate? Not 100% sure what you mean!

txbakers

4:49 pm on Sep 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What he was suggesting is that you use a series of checkboxes (or a drop-down) that allows the user to select a format for dates. They would enter whatever they wanted in the input box and based on their selection you would format the date that way.

Kind of a pain.

I just saw something on javascripts.com which might be nice to use:
webdeveloper.earthweb.com/repository/javascripts/2001/07/54631/datedd.htm

jatar_k

5:20 pm on Sep 13, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would say just implement the drop downs and explain to him that the validation processes to ensure data integrity will take x+5 hrs at $x/hr and that the drop downs will take, roughly, 2 mins. Maybe that will sway him.

chowcat

6:03 pm on Sep 13, 2002 (gmt 0)



yep, the drop downs definitely seem to be the better option, less work for me in the long run as well! :) You know how it is, always have to do something 10 times before the boss realises that the only way it's going to work is the way you suggested in the first place.

New problem - how to fit 3 drop downs on one row that can't be more than 220 pixels wide.....:)

txbakers

6:14 pm on Sep 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



use numbers for the months instead of words, use 2 digit years for the option and 4 digit for the value

mivox

7:16 pm on Sep 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alternatively, to avoid drop downs, break the date up into 3 separate text entry boxes, with one set to only allow 4 digits (for the year), one set to only allow 2 digits (for the date), and one set to allow a maximum of 9 letters (for the month)... and label each one:

M:[xxxxxxxx] D:[00] Y:[0000]

chowcat

11:43 am on Sep 14, 2002 (gmt 0)



that seems to have done the job, my boss gets his form results through as he wants them and the enquirer is limited as to what format they can enter the date in, plus css on the text boxes shrinks them down enough to fit on one row. (in I.E. and Netscape 6 anyway) Thanks.