By default, the label element is used to display the verification prompt information and css class is added, css allows you to easily set error controls and display methods of error messages.
/* Input control verification error */
Form input. error {border: solid 1px red ;}
/* Verification error message */
Form label. error {width: 200px; margin-left: 10px; color: Red ;}
To customize the display mode, you can modify the default display mode of jquery. validate.
The label is used by default to Display error messages, which can be modified through the errorElement attribute.
ErrorElement: html tag of the error message
$ (". Selector"). validate
ErrorElement: "em"
})
You can use other elements to wrap a layer in the error message.
Wrapper: the html Tag is encapsulated in the outer layer of the error message.
$ (". Selector"). validate ({
Wrapper: "li"
})
The default css class for verification errors is error, which can be modified through errorClass.
ErrorClass: the css class used for error Verification
Also customize the action when the verification is successful
Success: If the value is a string, it is treated as a css class. If it is a function, it is executed.
$ (". Selector"). validate ({
Success: "valid"
})
Or
Success: function (label ){
Label.html (""). addClass ("checked ");
}
You can also unify the error messages to a container for display.
ErrorLabelContainer: Unified error messages to a container for display.
By default, error messages are placed after verification elements. You can customize the display location of error messages.
$ (". Selector"). validate ({
ErrorPlacement: function (error, element ){
Error. appendTo (element. parent ("td"). next ("td "));
}
})
Further, you can define a group to unify the error information in several places and use the error Placement to control where the error information is stored.
Groups: defines a group.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service