Control the format

D

Daviso

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
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Fri, 10 Feb 2006
11:34:18 remote, seen in Daviso
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top