Skip to content

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

Closed
@nebrot

Description

@nebrot

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions