Parameter dependency- expression type: String An expression (String) in the form context. Whether the form elements need to be filled in depends on the expression returning one or more elements.
Description: Make the form elements must be filled in (selected), depending on the return value of the parameter.
Selection filters like #foo:checked, #foo:filled, #foo:visible will be frequently used in expressions.
Parameter dependency-callback Type: Callback The The return function takes the form element to be validated as its only parameter. When the callback function returns true, the form element is required.
Description: Make the form elements must be filled in (selected), depending on the return value of the parameter.
Selection filters like #foo:checked, #foo:filled, #foo:visible will be frequently used in expressions.
Js code
$("#myform").validate({
rules: {
age: {
required: true,
min: 3
},
parent: {
required: function(element) {
return $("#age").val() < 13;
}
}
}
});
$("#age").blur(function() {
$("#parent").valid ();
});
[4] remote( options ) Return: Boolean
Parameter options Type: String, Options url (String) for requesting server-side resources. Or Options in the $.ajax() method.
The server-side resource obtains the key/value pair through $.ajax (XMLHttpRequest). If the response returns true, the form passes the verification.
Js code
$("#myform").validate({
rules: {
email: {
required: true,
email: true,
remote: "check-email.php"
}
}
} );
[5] minlength( length ) Return: Boolean
Parameter length Type: Integer The minimum number of characters required.
Description: Make sure the form elements meet the given minimum number of characters.
Too few characters are entered in the text input, not enough checkboxes are selected, and not enough options are selected in a select box. In these three cases, this method returns false.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
minlength: 3
}
}
});
[6] maxlength( length ) Return: Boolean
Parameter length Type: Integer The maximum number of characters allowed to be entered.
Description: Make sure the text of the form element does not exceed the given maximum number of characters.
Entering too many characters into the text input box (text input), selecting too many check boxes (check boxes), and not selecting too many options in a selection box (select). In these three cases, this method returns false.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
maxlength: 4
}
}
});
[7] rangelength( range ) Return: Boolean
Parameter range Type: Array The range of characters allowed to be entered.
Description: Ensure that the number of text characters of the form element is within the given range.
The number of characters entered in the text input box is not within the given range, the selected checkbox is not within the given range, and the option selected in a select box is not within the given range. In these three cases, this method returns false.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
rangelength: [2, 6]
}
}
});
[8] min( value ) Returns: Boolean
Parameter value type: Integer The minimum integer that needs to be input.
Description: Ensure that the value of the form element is greater than or equal to the given minimum integer.
This method is only valid in the text input box (text input).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
min: 13
}
}
});
[9] max( value ) Return: Boolean
Parameter value type: Integer The maximum integer given.
Description: Ensure that the value of the form element is less than or equal to the given maximum integer.
This method is only valid in the text input box (text input).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
max: 23
}
}
});
[10] range( range ) Return: Boolean
Parameter range type: Array The given integer range.
Description: Ensure that the value of the form element is within the given range.
This method is only valid in the text input box (text input).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
range: [13, 23]
}
}
});
[11] email( ) returns: Boolean
Description: Make sure the value of the form element is a valid email address.
Returns true if the value is a valid email address. This method is only valid under text input box (text input).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
email: true
}
}
});
[12] url( ) return :Boolean
Description: Make sure the value of the form element is a valid URL address (http://www.mydomain.com).
Returns true if the value is a valid url address. This method is only valid under text input box (text input).
Description: Used to verify valid dates. The date formats verified by these three functions are (mm/dd/yyyy), (yyyy-mm-dd,yyyy/mm/dd), and (mm.dd.yyyy) respectively.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
date: true
/*dateISO: true
dateDE: true*/
}
}
});
[14] number( ) numberDE() Return: Boolean
Description: Used to verify decimals. The decimal point of number() is a dot ( . ), and the decimal point of numberDE() is a comma ( , ).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
number: true
//numberDE: true
}
}
});
[ 15] digits() Return: Boolean
Description: Make sure the value in the text box is a number.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
digits: true
}
}
});
[16] digits() return :Boolean
Description: Make sure the value in the text box is a number.
Js code
$("#myform").validate({
rules: {
field: {
required: true,
digits: true
}
}
});
[17] accept( [extension ] ) Return: Boolean
Parameter extension (Optional) Type: String Allowed file suffix name, separated by "|" or ",". The default is "png|jpe?g|gif"
Description: Ensure that the form element receives the file with the given file extension. If no parameters are specified, only images are allowed (png, jpeg, gif).
Js code
$("#myform").validate({
rules: {
field: {
required: true,
accept: "xls|csv"
}
}
});
[18] equalTo( other ) Returns: Boolean
Parameter other Type: Selector Another form element to be compared with the current value.
Description: Make sure the values of the two form elements are consistent.
Js code
$("#myform").validate({
rules: {
password: "required",
password_again: {
equalTo: "#password"
}
}
});
Copy Code
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