[RESOLVED] [2005] MakedTextBox Time Validation
Greetings,
I am using a MaskedTextBox. The Mask is 90:00 Time of the Type DateTime.
How can I make sure the user is not entering 30:99 or something else users normaly try :rolleyes:
I also get a little bit confused should I use the Validating Event or the TypeValidationComleted Event?
Thanks in advance
Re: [2005] MakedTextBox Time Validation
Found a regular expression pattern on the net
Code:
^([0-1][0-9]|[2][0-3]):([0-5][0-9])$
but I never used RegExpr.
Help would be great. thx
Re: [2005] MakedTextBox Time Validation
Don't use a MaskedTextBox or a Regex for time. Use a DateTimePicker. Set the Format to Time or Custom if you don't want the standard time format. If you want 24 hour time then set the CustomFormat to "HH:mm". Finally set the ShowUpDown to True so there's no drop-down calendar. There's now no validation needed because the control handles it all for you. You get a DateTime object from the control's Value property. If you want a TimeSpan object then get the Value.TimeOfDay property.
Re: [2005] MakedTextBox Time Validation
@jmcilhinney:
Many thanks for your idea. Does exactly what i wanted :afrog: