its original state before verification/*validator.showerrors ({"FirstName": "I know that your FirstName was Pete, pete!"}); Display custom Error Messages */if (Formstate==false) {Return}else{Do someing ...}})Using AJAX to authenticate, the default is to submit the current validated value to the remote address, if you need to commit additional values, you can use the data option background only allowed to return false and TrueRemote: "check-email.php"
: $. validator. format ("Please enter a value between {0} and {1 }."),Max: $. validator. format ("Please enter a value less than or equal to {0 }."),Min: $. validator. format ("Please enter a value greater than or equal to {0 }.")
Usage
1:Use the default verification rules in the control, for example:Email (required)2:You can customize verification rules in the control, for example:Custom (required, [3, 5])messages:{required:'为什么不输入一点文字呢',minlength:'输入的太少了',maxlength:'输入那么多干嘛'}}">
3:
Use validate to do form verification, the effect is as shown in figure:
Of course, can also be changed to Chinese (if you feel that the default message is not what you want, you can also customize the hint message)
Validate Use steps:1. Import Jquery.js2. Import Validate.js3. Verify the form after the page has been
Previously, AJAX was implemented one by one using Javascript scripts, Which is cumbersome. After learning Jquery, I feel that it is not that difficult to implement AJAX. Of course, in addition to the Jquery framework, there are other excellent frameworks. Here I will focus on the popular Jquery.
Previously, Ajax was implemented one by one using JavaScript scripts, Which is cumbersome. After learning jquery, I feel that it is not that difficult to implement Ajax. Of course, in addition to the jquery framework, there are other excellent frameworks. Here I will focus on the popular jquery.
Detailed description of the jQuery validation plug-in Validate, jqueryvalidate
The most common use of JavaScript is form verification. jQuery, as an excellent JavaScript library, also provides an excellent form verification plug-in-Validation. Validation is one of the oldest
JQuery. Validate verification Library1. Download jquery. validate, here I provide jquery-validation-1.9.0, click to download
Default verification rules
Copy codeThe Code is as follows: (1) required: true mandatory field
(2) remote: "check. php" uses ajax to call check. php t
Quick Solution that JQuery. validate does not support in ie8, jquery. validateie8
I. Back the problematic code in ie8
1. The JQuery. validate verification framework verifies whether the input in the
The name attribute is consistent with the attribute in the rules in the fo
credit card number.", Equalto:"Please enter the same value again.", Accept:"Please enter a value with a valid extension.", MaxLength: $.validator.format ("Please enter no more than {0} characters."), minlength: $.validator.format ("Please enter at least {0} characters."), Rangelength: $.validator.format ("Please enter a value between {0} and {1} characters long."), Range: $.validator.format ("Please enter a value between {0} and {1}."), Max: $.validator.format ("Please enter a value of less tha
Verify the operation class formvalidatorclass. js
CopyCode The Code is as follows :/**
* @ Author Ming
*/
$ (Document). Ready (function (){
/** // * Set the default attribute */
$. Validator. setdefaults ({
Submithandler: function (form ){
Form. Submit ();
}
});
// Character Verification
Jquery. validator. addmethod ("stringcheck", function (value, element ){
Re
})Set Debug to Default:$.validator.setdefaults ({
Debug:true
})Submithandler:
A function that is run after validation is added to the form, or the form will not be submitted$ (". Selector"). Validate ({
Submithandler:function (form) {
$ (form). Ajaxsubmit ();
}
})Ig
the following format: Name1=value1name2=value2. This method returns a string.
Instance:
var querystring = $ (' #myFormId. Specialfields '). Fieldserialize ();
5.fieldValue
Returns the form element values that match the inserted array. From version 0.91, the method will always return data as an array. If the element value is determined to be invalid, the array is empty, otherwise it will contain one or more element values. The method re
When using Vee-validate to use the Chinese version hint, the vee-validate version needs to be noted"Vee-validate": "2.0.0-rc.25"Add the following code to the Main.jsImport veevalidate, {Validator} from ' Vee-validate' vee-validate
Asynchronous form data submission using jquery ajax
The ajax method of jquery can be used to submit forms asynchronously. After successful submission, json data is returned in the background and the callback function is used for processing. You do not need to refresh the page for asynchronous purposes;
The data proces
you enter a text? ', minlength: 'too few inputs', maxlength: 'What are so many inputs '} "/>
3: using JavaScript custom verification rules, the following JavaScript custom two rules, password and confirm_password copy Code the code is as follows: $ (). ready (function () { $ ("# form2 "). validate ({ rules :{ minlength: 5 }, confirm_password: { required: True, minlength: 5, failed to: "# passwo
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 string with a valid suffix name",Maxlength:jQuer
JQuery is a fast, simple JavaScript library that simplifies the traversing of HTML files, event handling, animation, Ajax interaction, and thus facilitates the rapid development of Web-page production. JQuery is designed to change the way you write JavaScript.
The JQuery Validate plug-in provides a powerful validation
JQuery. validate does not support solutions in ie8. jquery. validateie8
I. Back the problematic code in ie8
1. The JQuery. validate verification framework verifies whether the input in the 1 The name attribute is consistent with the attribute in the rules in the following js
We sometimes encounter this situation in web development, such as the collection of user information from a site, submitted to the B site processing, this time will be related to cross-domain submission of data issues. This article will show you how to use jquery to implement asynchronous cross-domain submission of form data.In jquery, we use the JSON data type t
array. If the element value is judged to be invalid, the array is empty, otherwise it will contain one or more element values. The method returns an array.Instance:Get password input value var = $ (' #myFormId:p assword '). Fieldvalue (); Alert (' The password is: ' + value[0]);6.resetFormRestores the form to its original state by invoking the original Dom method of the form element.Instance:$ (' #myFormId
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.