Jump to content

Script to validate both date and time formats?


Moron

Recommended Posts

Users like to enter dates in so many different formats that I've always found the best solution to date/time entry is to give them a 'date picker' that places their selection into a text box on the form.  If they then decide to fool around with what's in the text box, they get what they deserve.  Meanwhile, users with IQs higher than room temperature will appreciate the ease of data entry provided by a date picker.

http://www.rainforestnet.com/datetimepicker.htm is excellent
Link to comment
Share on other sites

[quote author=AndyB link=topic=107380.msg430977#msg430977 date=1157758553]
Users like to enter dates in so many different formats that I've always found the best solution to date/time entry is to give them a 'date picker' that places their selection into a text box on the form.  If they then decide to fool around with what's in the text box, they get what they deserve.  Meanwhile, users with IQs higher than room temperature will appreciate the ease of data entry provided by a date picker.

http://www.rainforestnet.com/datetimepicker.htm is excellent
[/quote]

I'm already using a popup calendar date picker. It works great, but as you implied, it's just a matter of time before someone decides to enter it "manually" and gets it wrong. Right now there is NO validation on these fields except that they can't be left blank. You can enter anything, even a string like askdnvioweh as the date and it'll go as long as it's not blank.

Link to comment
Share on other sites

Bump.

Anybody seen a script like this? I'm finding everything BUT what I'm looking for.

Some calculate date differences. Don't need that.

Some allow standard or military time. Don't need military.

Some validate everything under the sun INCLUDING what I'm looking for, but crash if I try to modify them.

All I need is:

[b]Start Date:[/b] Must be mm/dd/yyyy format.
[b]Start Time:[/b] Must be hh:mm format. No military time, no GMT, no AM/PM.
[b]End Date:[/b] Must be mm/dd/yyyy format.
[b]End Time:[/b] Must be hh:mm format. No military time, no GMT, no AM/PM.
[b]Total Hours:[/b] Can't be left blank.

Anybody seen something similar without a bazillion features I don't need?
Link to comment
Share on other sites

I use a date picker also and they way I keep users from manipulating it is take make the INPUT field read only. Like this:

[code]<INPUT id="date" style="WIDTH: 75px" type="text" name="date" value="" title="Year-Month-Day Format." readOnly>[/code]

The date picker drops the selected value right in the box, but the user cannot make a change to it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.