|
-
Feb 12th, 2007, 08:11 AM
#1
Thread Starter
Hyperactive Member
[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
I also get a little bit confused should I use the Validating Event or the TypeValidationComleted Event?
Thanks in advance
Last edited by Bongo; Feb 12th, 2007 at 08:24 AM.
-
Feb 12th, 2007, 09:01 AM
#2
Thread Starter
Hyperactive Member
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
-
Feb 12th, 2007, 06:18 PM
#3
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.
-
Feb 13th, 2007, 12:49 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] MakedTextBox Time Validation
@jmcilhinney:
Many thanks for your idea. Does exactly what i wanted
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|