Form / Form validation

Form / Form validation

At its core, the web form is a specially limited area on the site page. In these areas, the visitor of the site can fill some information and also choose specific actions from the offered lists. The web form on the site is an analog of a paper form or questionnaire.

form and form validation

The forms have fields for filling, as well as lists and switches that allow the user to select one or more items. The form can be used to receive information from site visitors. For example, by using web forms sites can collect personal data, information about orders, information that is necessary for billing, information about delivery methods and so on. Visitors are required to enter various kinds of information in the form fields. The above information can be specified by switches, check boxes, drop-down lists and entering information into text fields. There’s also the ability to specify how to collect information that site visitors enter, as well as how to display the results on the confirmation page that the users are viewing. The form can function only if it’s supported by the web server. Elements of the form are called the form fields. The form fields are not only text fields, but switches, buttons and other elements.

Fields in the forms are designed to collect information from visitors. But despite all the efforts and explanations, getting the right information can be difficult. Impatient or inattentive visitors can skip important fields, fill several fields incompletely, or simply press the wrong keys. Then they click the “Send” button, and the server gets a set of data with which it doesn’t know what to do. A serious website requires form validation, i. e. any way to detect errors in the input data. Or even better, a method that doesn’t allow errors at all. Over the years, web developers have done this through JavaScript procedures or through professional JavaScript libraries. And these approaches were giving excellent results.

But the verification is needed everywhere, but applies only to several basic data types (for example, e-mail addresses and dates). And also its implementation is such an uninteresting and boring task (in fact, nobody wants to write the same code for each form, let alone testing it every time). So, the creators of HTML5 invented a way to help web developers by reassigning the task of form validation to web browsers. The creators of HTML5 have developed a client-side validation system that allows the web developers to insert basic validation rules into any <input> tag.

Related terms:

HTML, HTML5, script, tag, JavaScript, PHP

References and further reading:

Code examples:

JavaScript Form Validation