Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2006, 08:51 PM   PM User | #1
bspahr
New Coder

 
Join Date: Apr 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
bspahr is an unknown quantity at this point
Time Validation Help

I have 2 fields; start time and end time. Is there a way to validate that they enter the times in the correct format? Ex. 12:00

Here is the basic code:
Start Time: <input type="text" name="startTime"> (HH:MM format)
End Time: <input type="text" name="endTime"> (HH:MM format)


I found the link below which is kind of what I'm looking for, but it has alot of extra stuff that I don't need. I just want to validate the hour and minute.
http://javascript.internet.com/forms/val-time.html
bspahr is offline   Reply With Quote
Old 12-04-2006, 09:00 PM   PM User | #2
Ancora
Banned

 
Join Date: Oct 2005
Location: I'm in GMT -5
Posts: 314
Thanks: 0
Thanked 1 Time in 1 Post
Ancora is on a distinguished road
I want, I want, I want....
Ancora is offline   Reply With Quote
Old 12-04-2006, 09:46 PM   PM User | #3
mrhoo
Regular Coder

 
Join Date: Mar 2006
Posts: 708
Thanks: 30
Thanked 127 Times in 118 Posts
mrhoo will become famous soon enoughmrhoo will become famous soon enough
var rx= /^([1-9]|(11)|(12)) *\: *[0-5][0-9] *$/;
rx.test(startTime)
mrhoo is offline   Reply With Quote
Old 12-04-2006, 10:27 PM   PM User | #4
bspahr
New Coder

 
Join Date: Apr 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
bspahr is an unknown quantity at this point
thanks mrhoo I will see if I can make that work. You want what Ancora?
bspahr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:24 PM.


Advertisement
Log in to turn off these ads.