//Custom verification $. Validator.addMethod ("ispositive", function (value, element) { var score = /^[0-9]*$ /; Return This.Optional (Element) || (score .test(value)); },"Please enter a number greater than 0");
User via addMethod You can customize your own verification rules
This method has three parameters. The first parameter indicates the name of the verification rule. Here is isPositive, indicating whether it is a positive number.
The second parameter is the real verification subject, which is a function. The first value of the function represents the value of the form that calls this verification rule. The second element can be used to determine whether it is empty. When it is empty, , this verification rule will not be called.
The third parameter is the error message returned.
How to use it specifically?
In fact, it is the same as the inherent validation rules of jquery validate.
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