Connecting Tech Pros Worldwide Help | Site Map

Control the format

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 10th, 2006, 10:45 AM
Daviso
Guest
 
Posts: n/a
Default Control the format

Hello.
I have an <input> into a html page. In this box, the user must introduce the
hour by hand. I want to control that the format is correct, for example:
10.35
22:50
etc... (just, one of them)
I have been looking for code to do this, but I can't find.
Anybody knows about this???
Thanks
David



  #2  
Old February 11th, 2006, 05:35 PM
Dr John Stockton
Guest
 
Posts: n/a
Default Re: Control the format

JRS: In article <dshtkp$59j$1@hefestos.uned.es>, dated Fri, 10 Feb 2006
11:34:18 remote, seen in news:comp.lang.javascript, Daviso
<dhernande7@alumno.uned.es> posted :[color=blue]
>I have an <input> into a html page. In this box, the user must introduce the
>hour by hand. I want to control that the format is correct, for example:
>10.35
>22:50
>etc... (just, one of them)
>I have been looking for code to do this, but I can't find.[/color]

You should not try to control the format as it is being constructed;
it's better to check that the field is valid before it is used. See
<URL:http://www.merlyn.demon.co.uk/js-valid.htm> and use something like
OK = /^\d\d[:\.]\d\d$/.test(S)

If those are times, maybe /^[0-2]\d[:\.][0-5]\d$/ - it's scarcely worth
bothering to rule out hours 24..29.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.