Skip to content
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

Wrong form validation for fields with type="date" and for example min="2022-05-13" #765

Closed
nebrot opened this issue May 13, 2022 · 2 comments · May be fixed by #767
Closed

Wrong form validation for fields with type="date" and for example min="2022-05-13" #765

nebrot opened this issue May 13, 2022 · 2 comments · May be fixed by #767

Comments

@nebrot
Copy link
Contributor

nebrot commented May 13, 2022

In our forms we are using date-fields and want to disallow dates from the past. Therefore we use the "min"-attribute:

var currentdate = new Date().toISOString().slice(0, 10);
$(".powermail_date").attr("min", currentdate).attr("data-powermail-minimum-message", "Date must be in the future!");

The browser-datepicker are correctly limited, but with keyboard you can type custom dates and then powermail-validation only works, if the year is not the current year probably because of a wrong compare in "isValidationMinimumConfirmed". I think fields with type "date" must be normalized before comparing values.
https://github.com/einpraegsam/powermail/blob/2930f72f2baf5b46f966c9262be2fbb7911e047b/Resources/Private/Build/JavaScript/FormValidation.js#L319-L325

Expected Behavior for min="2022-05-13":

Input "01-01-2021" => NOT allowed input
Input "01-01-2022" => NOT allowed input
Input "31-05-2022" => allowed input

Actual Behavior for min="2022-05-13":

Input "01-01-2021" => NOT allowed input
Input "01-01-2022" => allowed input <-- BUG
Input "31-05-2022" => allowed input

TYPO3: 11.5.10
Powermail: 10.1.0
Tested with different browsers (german format dd.mm.yyyy)

@einpraegsam
Copy link
Collaborator

I just checked but min and max is not supported by default in powermail for date fields.
So I'm going to close this issue.
Nevertheless if you are interested in doing a pull request with the change, we can run the automatic tests and if everything works as expected, I could merge the PR (if it's not a code mess :)

@nebrot
Copy link
Contributor Author

nebrot commented May 16, 2022

@einpraegsam I have submitted a PR #767, hope it works and you can merge it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants