Skip to content

Commit

Permalink
Core: Fix validation for input type="date" (#2359)
Browse files Browse the repository at this point in the history
Test case contributed by @nenadvicentic
  • Loading branch information
tyomitch committed Dec 9, 2021
1 parent e87008c commit 23fde62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -1215,7 +1215,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
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" } );
} );

0 comments on commit 23fde62

Please sign in to comment.