Form Validation

In this lesson, we will go over the concept of form validation.

When you collect information on a web page, nothing prevents your users from providing something different than what you ask for. For example, they may leave a textbox empty, type names where you expect numbers, provide a phone number instead of an e-mail address, and so on. When they click the submit button, all data goes to the server as it is filled out.

If your server-side does not validate the data, it could get wrong information which leads to errors and confusion. It is trivial that the server-side checks all data coming from the browser, the browser—the server-side must not trust that the client-side sends valid data.

However, sending invalid data to the server-side consumes resources: the form data goes to the network, it reaches the server, the server carries out validation procedures, and it sends back an answer saying that something is wrong with the input.

Get hands-on with 1200+ tech skills courses.