Skip to content

Core: fix validation for input type="date" #2360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ $.extend( $.validator, {

// Exception: the jquery validate 'range' method
// does not test for the html5 'range' type
rules[ method ] = true;
rules[ type === "date" ? "dateISO" : method ] = true;
}
},

Expand Down
5 changes: 5 additions & 0 deletions test/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,8 @@ QUnit.test( "required method should return false for undefined & null values", f
assert.notOk( v.element( username ), "The username element should be invalid" );
assert.notOk( v.element( urlc ), "The urlc element should be invalid" );
} );

QUnit.test( "rules() - returns dateISO for input type=date", function( assert ) {
$( "#rangesMinDateInvalid" ).validate();
assert.deepEqual( $( "#minDateInvalid" ).rules(), { dateISO: true, min: "2012-12-21" } );
} );