mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-24 12:13:59 +01:00
Core: Trigger success on optional but have other successful validators
The comment in the code itself says "when there are no other rules" but does nothing to enforce that comment. Fixes gh-851 Closes gh-852
This commit is contained in:
committed by
Jörn Zaefferer
parent
adbc6361c3
commit
f93e1deb48
30
test/test.js
30
test/test.js
@@ -902,7 +902,8 @@ test("successlist", function() {
|
||||
equal(0, v.successList.length);
|
||||
});
|
||||
|
||||
test("success isn't called for optional elements", function() {
|
||||
|
||||
test("success isn't called for optional elements with no other rules", function() {
|
||||
expect(4);
|
||||
equal( "", $("#firstname").removeAttr("data-rule-required").removeAttr("data-rule-minlength").val() );
|
||||
$("#something").remove();
|
||||
@@ -913,7 +914,7 @@ test("success isn't called for optional elements", function() {
|
||||
ok( false, "don't call success for optional elements!" );
|
||||
},
|
||||
rules: {
|
||||
firstname: "email"
|
||||
firstname: { required: false }
|
||||
}
|
||||
});
|
||||
equal( 0, $("#testForm1 label").size() );
|
||||
@@ -923,6 +924,31 @@ test("success isn't called for optional elements", function() {
|
||||
equal( 0, $("#testForm1 label").size() );
|
||||
});
|
||||
|
||||
test("success is called for optional elements with other rules", function() {
|
||||
expect(1);
|
||||
|
||||
$.validator.addMethod("custom1", function() {
|
||||
return true;
|
||||
}, "");
|
||||
|
||||
var v = $("#testForm1clean").validate({
|
||||
success: function() {
|
||||
ok( true, "success called correctly!" );
|
||||
},
|
||||
rules: {
|
||||
firstname: {
|
||||
required: false,
|
||||
custom1: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#firstnamec").valid();
|
||||
|
||||
delete $.validator.methods.custom1;
|
||||
});
|
||||
|
||||
|
||||
test("success callback with element", function() {
|
||||
expect(1);
|
||||
var v = $("#userForm").validate({
|
||||
|
||||
Reference in New Issue
Block a user