Skip to content

Commit

Permalink
Fixed #189 - :hidden elements are now ignored by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hdragomir authored and jzaefferer committed Sep 15, 2011
1 parent 665f67d commit 2170712
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -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
---
Expand Down
2 changes: 1 addition & 1 deletion jquery.validate.js
Expand Up @@ -214,7 +214,7 @@ $.extend($.validator, {
errorContainer: $( [] ),
errorLabelContainer: $( [] ),
onsubmit: true,
ignore: [],
ignore: ":hidden",
ignoreTitle: false,
onfocusin: function(element) {
this.lastActive = element;
Expand Down
27 changes: 27 additions & 0 deletions test/test.js
Expand Up @@ -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");
});

3 comments on commit 2170712

@Pathz88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi all... i have my div structure like this. only parent div is display none and child elements don't support for ignore:":hidden". what should i do..?

div id="divDepartmentArea" runat="server" style="display: none" clientidmode='Static'
div class="marginTop"
asp:TextBox ID="txtFrom" runat="server" ClientIDMode="Static" data-required="true"asp:TextBox
asp:TextBox ID="txtTo" runat="server" ClientIDMode="Static" data-required="true"asp:TextBox
/div
/div"

@staabm
Copy link
Member

@staabm staabm commented on 2170712 Sep 27, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pathz88 please open a new issue describing your problem in more detail

@Pathz88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staabm i'm new to github and don't know much about creating issues.. but i think i made a one. you can find it in below link
#1595

please help me..

Please sign in to comment.