To put it simply, the jQuery validation plug-in is used to verify whether the content entered by the elements in the form meets the business rules. If not, it can give user-defined prompt information. The plug-in not only has some verification rules by default, such as verifying whether the content is empty and whether the length of the content meets the given value, but also can customize business rules according to the user, and the error message can also be customized according to the user's requirements. show. It seems that the function of this plug-in is indeed very powerful. I can’t wait to use it. Okay, let's start with an introduction to how to use it.
jQuery validation plug-in download address: http://plugins.jquery.com/project/validate
In order to use this plug-in, we need to use the method validate({options});
Let us First, let’s take a quick look at the options that plug-ins often use:
•rules: consists of key/value, where key is equal to the form element ID and value represents the business rules that the form element content needs to meet.
•Messages: consists of key/value, key is equal to the form element ID and value represents the content that needs to be displayed because the form element content does not meet certain business rules.
•errorLabelContainer: Specify a container element that has been defined on the page to put error information.
•errorContainer: Represents a main content area within errorLabelContainer.
•wrapper: means defining an element in the errorLabelContainer element to wrap error information.
•onsubmit: Verify before submitting the form. It can be set to false to verify by adding other events.
•highlight: Highlight content areas with invalid input.
•unhighlight: Restore the originally highlighted area.
-------------------------------------------------- ----------------------------------
Now we start to simply implement user login page verification by using the jQuery validation plug-in Function:
1. Introduce plug-in: