0

I have using c#.net.

I have a textbox which should contain a time. It needs to be in 24 hour format.

I would like to use a CustomValidator but can’t find anything on the net.

Thanks in advance for any help

Clare

Canavar
  • 47,715
  • 17
  • 91
  • 122
ClareBear
  • 1,493
  • 6
  • 25
  • 47

2 Answers2

1

For using CustomValidator check this link, but I prefer regular expression validator instead.

Check this question about validation of time with Regular Expression Validator :

Regular expression to validate valid time

Community
  • 1
  • 1
Canavar
  • 47,715
  • 17
  • 91
  • 122
  • I have added the RegularExpressionValidator (RegEx taken from the other post). However even though the time is incorrect it still allows me to update (update button) do I need to do client side validation? – ClareBear Sep 24 '09 at 09:27
  • If you would like to block the user from saving the form after inputting an incorrect time then you'll need at least server side validation- and client-side validation isn't a bad idea either. Can you post your code in the original question? – Nathan Taylor Sep 24 '09 at 13:48
1

Use this "([01]?[0-9]|2[0-3]):[0-5][0-9]" regular expression in regular expression validator