Home  >  Article  >  Web Front-end  >  Implement form validation based on Bootstrap+jQuery.validate

Implement form validation based on Bootstrap+jQuery.validate

高洛峰
高洛峰Original
2017-01-03 17:36:321274browse

This is probably a common practice. The first business you come into contact with when learning the front and backends is user registration and login. Nowadays, society adheres to the people-oriented concept, and the same is true in the website development process. User is the object we face most, and it is also the most core object. The initial user registration and login are particularly important.

User registration and login are often more difficult than we think. For example, form verification actually covers a lot of content. As far as the front desk is concerned, you need to understand:

1. Basic understanding of regular expressions

In fact, regular expressions are not difficult, and It will give you a great sense of accomplishment after learning it, and enjoy the effect of getting twice the result with half the effort.

2.ajax asynchronous request

Provides corresponding prompts when verifying whether the user name exists or when the user logs in with an incorrect account or password.

3. Some convenient validation libraries, such as jQuery.validate

Because of such common needs and certain complexity, some excellent classes such as bootstrap form and jQuery.validate form verification The library is designed to solve UI and form validation problems for people.

The following is the interface I made using bootstrap+jQuery.validate:

Implement form validation based on Bootstrap+jQuery.validate

Implement form validation based on Bootstrap+jQuery.validate

##1. Bootstrap3 basic forms and levels Form

1. Basic form

The basic form structure comes with Bootstrap. The steps to create a basic form are listed below:

To the parent element
Add role="form".

Put labels and controls in a

with class .form-group. This is necessary to obtain optimal spacing.
Add class .form-control to all text elements ,
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn