Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #189 - :hidden elements are now ignored by default

  • Loading branch information...
commit 21707129666012f6b0bc60622eb3bcb9f87daa04 1 parent 665f67d
@hdragomir hdragomir authored committed
Showing with 29 additions and 1 deletion.
  1. +1 −0  changelog.txt
  2. +1 −1  jquery.validate.js
  3. +27 −0 test/test.js
View
1  changelog.txt
@@ -13,6 +13,7 @@
* Fixed #184 - resetForm: should unset lastElement
* Fixed #71 - improve existing time method and add time12h method for 12h am/pm time format
* Fixed #177 - Fix validation of a single radio or checkbox input
+* Fixed #189 - :hidden elements are now ignored by default
1.8.1
---
View
2  jquery.validate.js
@@ -214,7 +214,7 @@ $.extend($.validator, {
errorContainer: $( [] ),
errorLabelContainer: $( [] ),
onsubmit: true,
- ignore: [],
+ ignore: ":hidden",
ignoreTitle: false,
onfocusin: function(element) {
this.lastActive = element;
View
27 test/test.js
@@ -1159,3 +1159,30 @@ test("validate radio on click", function() {
trigger(e1);
errors(0);
});
+
+test("ignore hidden elements", function(){
+ var form = $('#userForm');
+ var validate = form.validate({
+ rules:{
+ "username": "required"
+ }
+ });
+ form.get(0).reset();
+ ok(! validate.form(), "form should be initially invalid");
+ $('#userForm [name=username]').hide();
+ ok(validate.form(), "hidden elements should be ignored by default");
+});
+
+test("ignore hidden elements at start", function(){
+ var form = $('#userForm');
+ var validate = form.validate({
+ rules:{
+ "username": "required"
+ }
+ });
+ form.get(0).reset();
+ $('#userForm [name=username]').hide();
+ ok(validate.form(), "hidden elements should be ignored by default");
+ $('#userForm [name=username]').show();
+ ok(! validate.form(), "form should be invalid when required element is visible");
+});
Please sign in to comment.
Something went wrong with that request. Please try again.