Use Masked TextBox
For this and put Validation on TextBox
Validating Event
Try this Link Phone Number Validation it may help you
How to pre-define the text box for e-mail and/or phone number
-
27-09-2022 - |
题
I am wondering if I have two text boxes for Phone and Mail how can I allow only digits (let's say US standard 1-234-567-8910) and only a real e-mail(aaaaaaa*@bbb.*cc) to my text boxes correspondingly in c#?
解决方案
其他提示
you can use a jQuery
plugin named mask
click here
In WinForms you can use the ErrorProvider
in conjunction with the Validating
event to handle the validation of user input. The Validating event provides the hook to perform the validation and ErrorProvider gives a nice consistent approach to providing the user with feedback on any error conditions. You can use regular-expression validation inside this event to check the pattern of email or phone number. More detail is HERE
不隶属于 StackOverflow