Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bytestream merged 3 commits intojquery-validation:masterfromtyomitch:master
May 6, 2022

Conversation

tyomitch
Copy link
Contributor

No tests here, because none are possible with methods from localization/ (quotinghttps://github.com/jquery-validation/jquery-validation/blob/master/test/methods.js#L186 : "need to figure out how to test localized methods")

Fixes#2359

nenadvicentic reacted with thumbs up emoji
@micschk
Copy link

Would be nice if this could be merged (assuming it indeed fixes date inputs).

nenadvicentic reacted with thumbs up emoji

@staabm
Copy link
Member

Could you verify wether it fixes the mentioned problem and also add a unit test?

nenadvicentic reacted with thumbs up emoji

@nenadvicentic
Copy link

nenadvicentic commentedDec 7, 2021
edited
Loading

Hi,

I tested this change onde culture and it seems to work fine.

Overwritten originalrules[method] = true line withrules[type === "date" ? "dateISO" : method] = true; andinput type=date client side validation started to work.

Is there any elegant way to monkey-patch this until the fix is officially released?

@staabm
Copy link
Member

In case we get a unit test for the expected behavior which passes with thxis change, we could merge the PR

@nenadvicentic
Copy link

In case we get a unit test for the expected behavior which passes with thxis change, we could merge the PR

I am not familiar with jQuery source or tests, so not sure if I personally can help. My intuition tells me, unit tests where forinput type=date jquery-validation method$(element).rules() returns{ dateISO: true} instead of current{ date: true } would be sufficeint.

@staabm Any tip where this test can be added/implemented?

@nenadvicentic
Copy link

@tyomitch,@staabm Boys, there example of your unit-test:

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

It can be added to/test/rules.js file. I used existinginput type=date element inindex.html -#minDateInvalid, which also containsmin rule.

@tyomitch ,@staabm How should we proceed with this?

@tyomitch
Copy link
ContributorAuthor

@nenadvicentic done, updated the patch with your test case.

The scenario whichshould be tested is that a localized date input passes validation; but perhaps@staabm can accept this as a passable approximation.

@nenadvicentic
Copy link

nenadvicentic commentedDec 10, 2021
edited
Loading

The scenario whichshould be tested is that a localized date input passes validation; but perhaps@staabm can accept this as a passable approximation.

By specification value property ofinput type=date is always formatted as ISO8601 dateyyyy-mm-dd regardless of localized formatting displayed by browser. Details can be found in Mozilla developer networkarticle.

So test thatdateISO validation is picked for<input type="date"> is enough.

Note: The displayed date format will differ from the actual value — the displayed date is formatted based on the locale of the user's browser, but the parsed value is always formattedyyyy-mm-dd.

@tyomitch ,@staabm : more I am thinking about this scenario, I am wondering if there is a need for validation at all in this case, since browser ensures that, ifvalue is there, it has to be in correct format.

@github-actions
Copy link

This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automatically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up.
Thank you for contributing :)

@github-actionsgithub-actionsbot added the staleUsed to mark stale issues labelMay 6, 2022
@tyomitch
Copy link
ContributorAuthor

I think this is wrong, and the problem still persists.

@bytestreambytestream merged commit350f6ae intojquery-validation:masterMay 6, 2022
@bytestreambytestream removed the staleUsed to mark stale issues labelMay 6, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

input type="date" fails validation when using locale specific methods from localizations/
5 participants
@tyomitch@micschk@staabm@nenadvicentic@bytestream

[8]ページ先頭

©2009-2025 Movatter.jp