They are:1. Basic usage: set verification rules through stylesCopy codeThe Code is as follows: When a form is submitted, an error occurs if no email is entered or the email is incorrect, as shown below:
The default prompt after the text box indicates that jquery can be modified. validate. min. js. Search for and replac
The most convenient way to use the jquery Validate plugin Reomte method is to infer whether a user account has been registered through an AJAX request during user registration.Jquery Validate plugin, call remote method validation parameters, remote use method:increase in the Validate methodRemote: "Calibration Method",
Jquery validate usage and extension rules, jqueryvalidateIndex.html
{Required: true, minlength: 5, failed to: '# password'} must be added to metadata. js if you need to use {} in the class.-->Custom Extension-->Jquery. validate. ext. js
// Re-write the prompt jQuery. extend
The verification methods of radio, checkbox, and select are not much different from those mentioned above, but the problem is that the error message is displayed after the first element in the same group. The effect is as follows:
The solution to this problem is to specify the error information to a specific location. The parameters of the validate () method can be customized. The sample code is as follows:
View code
Script Type
=
"
Jquery. Validate. JS is a front-end verification control based on the jquery library. It has powerful functions and integrates many common verification methods. Very convenient. As follows:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
//
Verify
$ (
Function
(){
//
After the document is loaded,
By default, the label element is used to display the verification prompt information, and CSS class is added. Through CSS, you can easily set the error control and display mode of error information.
/* 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 displa
The preceding example shows that the self-contained verification method in validate is sufficient to meet General requirements. For special requirements, you can use addmethod (name, method, message) to add custom verification rules, the following example adds an extension Verification Method for regular expression verification. The example is as follows:
Script Type
=
"
Text/JavaScript
"
>
Jque
Recently, asp.net mvc4 was used. There is a need to implement the jquery validate verification message prompt in the pop-up box. The default jquery. validate. unobtrusive. js implementation does not have such a function. You only need to modify it to meet our needs.Add onDialog:Function onDialog (errmap, errorList ){Va
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 mo
When you log on to the registration module, we need to ask the user to fill in the information according to our rules. If the information is verified directly after the information is submitted, the form-validate control is a powerful form verification control, including simple rule verification and asynchronous verification, the control can customize verification rules. it is convenient and practical.After downloading form-
The JQuery Validate plugin provides a powerful validation feature for forms, making it easier to validate client forms, while providing a number of customization options to meet the needs of your application. The plugin bundles a set of useful validation methods, including URL and email validation, and provides an API
Recently have a project, use a lot of form check, try a bit jquery.validator, very conveniently, address: http://plugins.jquery.com/project/validate, basic usage:
The code is as follows
Copy Code
$ (' #formId '). Validate ({Debug:true,//Open debug mode, not true submission, suitable for testingrules:{UName: "Required",//need to be enteredunick:{Required:trueAnother form of writi
By default, the label element is used to display the verification prompt information, and CSS class is added. Through CSS, you can easily set the error control and display mode of error information.
/* 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 displa
Overview: This article mainly discusses jquery.validate combined with Jquery.form to implement the verification and submission scheme of the form.
Mode one: It is through the jquery.validate submithandler option, that is, the callback function is executed when the form is validated. Submits the form through Jquery.form in this callback function;
Mode two: It is through the Jquery.form Beforesubmit, the callback function that executes before submitting the form, which, if returned true, submits
Defining Chinese messagesvar cnmsg = {Required: "Required field",Remote: "Please fix this field",Email: "Please enter the correct format of e-mail",URL: "Please enter a valid URL",Date: "Please enter a valid date",Dateiso: "Please enter a valid date (ISO).",Number: "Please enter a valid digit",Digits: "Can only enter integers",CreditCard: "Please enter a valid credit card number",Equalto: "Please enter the same value again",Accept: "Please enter a str
$ ("#commentForm"). Validate (): On it, what parameters should be added ...
Registration information authentication text message $ (function () {JQuery.validator.addMethod ("IsMobile", function (value, Element) {var length = Val
Ue.length; return this.optional (Element) | | (length = /^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1}))
+\D{8}) $/.test (value)); "Please fill in your phone number correctly."
"); Entry into force $ ("#signup
jquery Validate date and ID card verification example
Here's validate's validate.js.
Jquery.extend (JQuery.validator.messages, {Required: "Must fill",Remote: "Please fix this field",Email: "Please enter the correct format email",URL: "Please enter a valid URL",Date: "Please enter a valid date",Dateiso: "Please enter
output other parameters.
9 add custom VerificationAddMethod: name, method, messageCustom Verification Method
Copy codeThe Code is as follows: // The text is in two bytes.
JQuery. validator. addMethod ("byteRangeLength", function (value, element, param ){
Var length = value. length;
For (var I = 0; I If (value. charCodeAt (I)> 127 ){
Length ++;
}
}
Return this. optional (element) | (length> = param [0] length }, $. Validator. format ("make sure that
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.