JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 24th, 2003, 12:34 PM
0kc0mputer 0kc0mputer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 0kc0mputer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Time Validation

Hi, I'm not too savvy with Javascript, and I need to be able to Validate a text box to make sure the user has input a valid time. I have seached quit a bit, and I have not found much information on how to do this.

Times accepted are military, HH:MM:SS AM/PM, HH:MM AM/PM, but I can restrict it to any of these if i need to.

Any Help would be appreciated.

Thanks

Reply With Quote
  #2  
Old July 24th, 2003, 01:37 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 16
You have a couple choices to make. Since it looks like you have opted to put it all in on text box (???), you can either parse the pieces using the javascript string functions or you can use a regular expression to validate: http://www.devguru.com/Technologies...ref/regexp.html

Since you seem to be allowing two different options of entering the text , you will probably want to go with a regular expression.


Now, if I were doing this, I'd break it up into its respective parts as dropdowns.
[hh] [mm] [ss] [ampm]

If you decided to leave off the [ampm] drop down then obviously your [hh] dropdown would need to go from 0 - 23, but if you keep the [ampm] you will have a twelve hour [hh] dropdown.

If you want to get really slick, just create both versions in a table or between <div></div> and have a radio or checkbox for the user to select which method they want to enter their time in (military or 12hour).

When the box is selected use dynamic html to show one or the other. You can easily disable the other elements so that they do not form post/get.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old July 24th, 2003, 01:51 PM
0kc0mputer 0kc0mputer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 0kc0mputer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yeah, if I had developed this backend on my own, I would've used drop-downs. In this case it is an already developed backend, and I have the task of adding CS Validations to these forms. If I wanted to use dropdowns, I'd have to develop a server-side script to examine an existing field value from a Record in a database, and create script to have the dropdowns select the existing time values.

I think I'll pass on making it slick. Thanks for the info.

Reply With Quote
  #4  
Old February 15th, 2004, 10:45 PM
aantony aantony is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 aantony User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Answer for your question

Confused:

Your answer is the following

^[0-9]+:[0-9]+ [aApP]+[mM]+$

Good day..

Anthony Antony

Times accepted are military, HH:MM:SS AM/PM, HH:MM AM/PM, but I can restrict it to any of these if i need to.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Time Validation


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap