Changeset 5561
- Timestamp:
- 05/12/08 11:04:58 (2 months ago)
- Location:
- trunk/plugins/validate
- Files:
-
- 3 modified
-
changelog.txt (modified) (1 diff)
-
jquery.validate.js (modified) (4 diffs)
-
test/test.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/validate/changelog.txt
r5559 r5561 13 13 * Fixed creditcard validation to accept only digits and dashes ("asdf" is not a valid creditcard number) 14 14 * Allow both button and input elements for cancel buttons (via class="cancel") 15 * Fixed #2215: Fixed message display to call unhighlight as part of showing and hiding messages, no more visual side-effects while checking an element and extracted validator.checkForm to validate a form without UI sideeffects 15 16 16 17 1.2.1 -
trunk/plugins/validate/jquery.validate.js
r5560 r5561 297 297 // http://docs.jquery.com/Plugins/Validation/Validator/form 298 298 form: function() { 299 this.prepareForm(); 300 var elements = this.elements(); 301 for ( var i = 0; elements[i]; i++ ) { 302 this.check( elements[i] ); 303 } 299 this.checkForm(); 304 300 jQuery.extend(this.submitted, this.errorMap); 305 301 this.invalid = jQuery.extend({}, this.errorMap); … … 308 304 this.showErrors(); 309 305 return this.valid(); 306 }, 307 308 checkForm: function() { 309 this.prepareForm(); 310 for ( var i = 0, elements = this.elements(); elements[i]; i++ ) { 311 this.check( elements[i] ); 312 } 313 return this.valid(); 310 314 }, 311 315 … … 449 453 check: function( element ) { 450 454 element = this.clean( element ); 451 this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass );452 455 453 456 // if radio/checkbox, validate first element in group instead … … 552 555 } 553 556 } 557 if (this.settings.unhighlight) { 558 for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) { 559 this.settings.unhighlight.call( this, elements[i], this.settings.errorClass ); 560 } 561 } 554 562 this.toHide = this.toHide.not( this.toShow ); 555 563 this.hideErrors(); 556 564 this.addWrapper( this.toShow ).show(); 565 }, 566 567 validElements: function() { 568 return this.elements().not(this.invalidElements()); 569 }, 570 571 invalidElements: function() { 572 return jQuery(this.errorList).map(function() { 573 return this.element; 574 }); 557 575 }, 558 576 -
trunk/plugins/validate/test/test.js
r5251 r5561 298 298 299 299 test("option: (un)highlight, custom", function() { 300 expect( 6);301 $("#testForm1 ").validate({300 expect(5); 301 $("#testForm1clean").validate({ 302 302 highlight: function(element, errorClass) { 303 303 equals( "invalid", errorClass ); … … 308 308 $(element).show(); 309 309 }, 310 errorClass: "invalid" 311 }); 312 var e = $("#firstname") 310 errorClass: "invalid", 311 rules: { 312 firstname: "required" 313 } 314 }); 315 var e = $("#firstnamec") 313 316 ok( e.is(":visible") ); 314 317 e.valid()