Validating user input in asp net web pages
Or she enters a random string of characters for her e-mail address?
Eventually, what you end up with is incorrect data being entered into your system.
Any time that you ask people for information, you have to be prepared for the unexpected.
You never know what they'll say when presented with a simple question.
If any of the information is formatted improperly, you need to alert the user to the errors in the input (done with the statements) and allow her to fix them before inserting the results into the data store (by simply redisplaying the page). However, this can get quite complex because you often have to check for multiple cases on each input.
For example, for the first name, you have to check that the field isn't blank, doesn't contain any numbers, doesn't contain spaces, and so on.
Today's lesson will cover the following: Imagine going to school to register for classes. If you tell him that your name is "56," he's going to wonder if you're telling the truth.Detecting invalid input is vital for presenting a solid application.Input validation also provides benefits for developersspecifically, coherent data.The user interface prompts the user for first and last name, e-mail address, street address, city, state, ZIP code, and phone number. Once the form is submitted, you have to verify that each field contains a valid entry before entering the data in a database.A common way to do this is through a series of statements, which display a message telling the user what the error is.