Skip to content

Commit

Permalink
resetForm should clear any aria-invalid values
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni authored and jzaefferer committed Oct 7, 2013
1 parent 3d5658e commit 4f8a631
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ $.extend($.validator, {
this.lastElement = null;
this.prepareForm();
this.hideErrors();
this.elements().removeClass( this.settings.errorClass ).removeData( "previousValue" );
this.elements()
.removeClass( this.settings.errorClass )
.removeData( "previousValue" )
.removeAttr( "aria-invalid" );
},

numberOfInvalids: function() {
Expand Down
17 changes: 16 additions & 1 deletion test/aria.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module("aria");

test("Invalid field adds aria-invalid=true", function() {
var ariafirstname = $('#ariafirstname');
var form = $('#ariaInvalid');
Expand All @@ -24,4 +24,19 @@ test("Valid field adds aria-invalid=false", function() {
ariafirstname.val('not empty');
ariafirstname.valid();
equal(ariafirstname.attr("aria-invalid"), "false");
equal($("#ariaInvalid [aria-invalid=false]").length, 1);
});

test("resetForm(): removes all aria-invalid attributes", function() {
var ariafirstname = $('#ariafirstname');
var form = $("#ariaInvalid");
var validator = form.validate({
rules: {
ariafirstname: "required"
}
});
ariafirstname.val('not empty');
ariafirstname.valid();
validator.resetForm();
equal($("#ariaInvalid [aria-invalid]").length, 0, "resetForm() should remove any aria-invalid attributes");
});

0 comments on commit 4f8a631

Please sign in to comment.