How to validate text in textbox control in winforms?
I have a control, where user have to put string, like “13:55”. I want to show MessageBox, when this value will be diffrent, than “XX:YY”.
How to do it?
In asp.net it was so easy to make, but how to implement it on winforms?
How to validate text in textbox control in winforms? I have a control, where
Share
Check out the MaskedTextBox if you don’t want to have to validate in the first place.
If you want to make the first digit optional:
Otherwise, you could use a regular expression. 4 digits separated by a colon would be:
@"^\d{2}:\d{2}$". (The@symbol prevents C# from treating ‘\’ as an escape character – nothing unique to regex.)