How to validate textboxes (C#)?
-
I am writing a program with a main form, when the user clicks on one of the menu buttons it will pop up another form. This form will have textboxes, I want to make sure all the textboxes have been filled out and that they contain the correct info (Most will require letters A-Z only but a few will be numbers 0-9 only). I do not want to use an error provider, I want to make it so when they click Ok if the textboxes aren't all as they should be it will show a messagebox saying what the error is (Either blank, or improper input in whatever textbox has the wrong input). I have no idea how to do this, all I can find are extremely technical explanations that don't help me. I know there's a validated and validating event but I don't have a clue how that works or what to do with it. Can anyone explain this to me? I don't feel like this is that complicated but I'm having a hard time finding an explanation that isn't overly technical.
-
Answer:
error provider needs validated and validating event to works. so the choices are by using them together, or manually validate all the textbox one by one..
Shintsu at Yahoo! Answers Visit the source
Other answers
You can use masked textbox. It is really easy to use and it can control what ever data u want the textbox to get! In this way u can't show message box as it doesn't accept the other characters But u can have a simple check on input with ascii codes. If it's a-z upper and lower case and 0-9 it means: 65-90 A-Z 97-122 a-z 48-57 0-9 for getting the ascii code: System.Text.ASCIIEncoding if not u can show a message box.
Ziba
cfedc
Sujon
Related Q & A:
- How to set the C++ standard in eclipse?Best solution by stackoverflow.com
- How to Convert a C++ Structure into C# Structure?Best solution by Stack Overflow
- How to pass a C structure in Python?Best solution by Stack Overflow
- How to validate US format phone number in Swift?Best solution by stackoverflow.com
- How to get a C.L.U.E. report?Best solution by realestate.about.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.