Connecting Tech Pros Worldwide Help | Site Map

Control the format

  #1  
Old February 10th, 2006, 11:45 AM
Daviso
Guest
 
Posts: n/a
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, 06:35 PM
Dr John Stockton
Guest
 
Posts: n/a

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.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unbound List Box Control Format, Rich Text, listbox display as rich text gcoaster answers 1 May 21st, 2008 01:20 PM
Control format of input lita answers 4 August 7th, 2007 01:57 AM
data binding DataTimePicker Control in vb.net 2005. h answers 1 April 25th, 2006 03:15 PM
Datalist control format JP answers 0 April 20th, 2006 04:55 PM
Control format property in OnFormat event Nigel C answers 1 November 13th, 2005 02:20 PM