@@ -902,7 +902,8 @@ test("successlist", function() {
902902 equal ( 0 , v . successList . length ) ;
903903} ) ;
904904
905- test ( "success isn't called for optional elements" , function ( ) {
905+
906+ test ( "success isn't called for optional elements with no other rules" , function ( ) {
906907 expect ( 4 ) ;
907908 equal ( "" , $ ( "#firstname" ) . removeAttr ( "data-rule-required" ) . removeAttr ( "data-rule-minlength" ) . val ( ) ) ;
908909 $ ( "#something" ) . remove ( ) ;
@@ -913,7 +914,7 @@ test("success isn't called for optional elements", function() {
913914 ok ( false , "don't call success for optional elements!" ) ;
914915 } ,
915916 rules : {
916- firstname : "email"
917+ firstname : { required : false }
917918 }
918919 } ) ;
919920 equal ( 0 , $ ( "#testForm1 label" ) . size ( ) ) ;
@@ -923,6 +924,31 @@ test("success isn't called for optional elements", function() {
923924 equal ( 0 , $ ( "#testForm1 label" ) . size ( ) ) ;
924925} ) ;
925926
927+ test ( "success is called for optional elements with other rules" , function ( ) {
928+ expect ( 1 ) ;
929+
930+ $ . validator . addMethod ( "custom1" , function ( ) {
931+ return true ;
932+ } , "" ) ;
933+
934+ var v = $ ( "#testForm1clean" ) . validate ( {
935+ success : function ( ) {
936+ ok ( true , "success called correctly!" ) ;
937+ } ,
938+ rules : {
939+ firstname : {
940+ required : false ,
941+ custom1 : true
942+ }
943+ }
944+ } ) ;
945+
946+ $ ( "#firstnamec" ) . valid ( ) ;
947+
948+ delete $ . validator . methods . custom1 ;
949+ } ) ;
950+
951+
926952test ( "success callback with element" , function ( ) {
927953 expect ( 1 ) ;
928954 var v = $ ( "#userForm" ) . validate ( {
0 commit comments