Home >Web Front-end >JS Tutorial >jQuery plus final own validation_jquery

jQuery plus final own validation_jquery

WBOY
WBOYOriginal
2016-05-16 18:42:241256browse
Copy code The code is as follows:

$.validator.setDefaults({
submitHandler: function() {
if ($("#username").val() != "" && $("#password").val() != "") {
form1.submit();
}
else {
if ($("#password").val() == "") {
$("#password").focus();
}
if ($("#username").val() == "") {
$("#username").focus();
}
}
}
});

This code can add custom jquery validation instead of relying solely on writing validation="{}" in the tag, or writing validation rules in code, which will all be in the Write an error message after the control to be verified.
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