Skip to content

Commit

Permalink
Core: fix validation for input type="date" (#2360)
Browse files Browse the repository at this point in the history
* Core: Fix code style to pacify jscs

* Core: Fix validation for input type="date" (#2359)

Test case contributed by @nenadvicentic

Co-authored-by: Kieran <kieran@supportpal.com>
  • Loading branch information
tyomitch and bytestream committed May 6, 2022
1 parent 7828568 commit 350f6ae
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 @@ -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
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 350f6ae

Please sign in to comment.