Click here to Skip to main content
15,924,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have time in 24 hours format like

11:25 and 14:24 etc .Now I have to validate these input values in textboxes.

Please help me how to validate it.




Thanking You
Mohd Wasif
Posted

One of the ways would be to use Regular expressions.

Try:
use regex: [0-2][0-9]\:[0-6][0-9]\:[0-5][0-9]

use regex: ([01]?[0-9]|2[0-3]):[0-5][0-9]

You can use it in JavaScript or code-behind as per your need.

Look here[^] for more.
 
Share this answer
 
v4
Comments
Ankur\m/ 10-May-11 2:46am    
That isn't 100% correct Sandeep. It will accept 28:69:59 (many such invalid combinations) which is wrong.
Sandeep Mewara 10-May-11 3:01am    
:doh:
Ankur\m/ 10-May-11 3:06am    
:confused:
Sandeep Mewara 10-May-11 3:07am    
:doh: was for myself! I missed that. Thanks for pointing it out. Corrected it.
Ankur\m/ 10-May-11 3:18am    
You still missed the seconds part. Add onemore :[0-5][0-9]
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900