In this chapter we are focusing on client-side validation.
Validation done in the browser is called client-side validation, while validation done on the server is called server-side validation. This is called form validation. When you enter data, the browser and/or the web server will check to see that the data is in the correct format and within the constraints set by the application. "Your password needs to be between 8 and 30 characters long and contain one uppercase letter, one symbol, and a number." (A very specific data format is required for your data)."Please enter a valid email address" (the data you entered is not in the right format)."Please enter your phone number in the format xxx-xxxx" (A specific data format is required for it to be considered valid)."This field is required" (You can't leave this field blank).
Go to any popular site with a registration form, and you will notice that they provide feedback when you don't enter your data in the format they are expecting. Read Website security for an idea of what could happen implementing server-side validation is somewhat beyond the scope of this module, but you should bear it in mind. However, client-side validation should not be considered an exhaustive security measure! Your apps should always perform security checks on any form-submitted data on the server-side as well as the client-side, because client-side validation is too easy to bypass, so malicious users can still easily send bad data through to your server. If it gets to the server and is then rejected, a noticeable delay is caused by a round trip to the server and then back to the client-side to tell the user to fix their data.
To understand what client-side form validation is, why it's important,Īnd how to apply various techniques to implement it.Ĭlient-side validation is an initial check and an important feature of good user experience by catching invalid data on the client-side, the user can fix it straight away.
Prerequisites:Ĭomputer literacy, a reasonable understanding of This article leads you through basic concepts and examples of client-side form validation.
This is called client-side form validation, and helps ensure data submitted matches the requirements set forth in the various form controls. Before submitting data to the server, it is important to ensure all required form controls are filled out, in the correct format.