JavaScript is not enabled in your browser. These examples will not work without JavaScript.

Forms: Validation

Form validation is necessary so that people don't send incorrect or even malicious data to your app or database. Validating a form field means code will check the entered data and provide visible error messages to the user; also, the form data will not be submitted until it validates!

There are two types of form validation: (1) Server-side happens on the Web server, after the form is submitted. (2) Client-side happens in the Web browser before the form is sent to the server. Client-side validation relies on JavaScript, so it's not 100 percent secure, because people can turn JavaScript off. Web professionals combine client-side techniques (fast and convenient for the users) with server-side (for security).

This example uses the Parsley jQuery library for client-side validation.

The Submit button will write text onto the page at the bottom, below the form. Here we have an added feature: The page will scroll to that position (jQuery again).

Note that the Reset button resets all form elements, but it does not reload the page.

Return to the index.