Validation for max/min date
See original GitHub issuePrerequisites
- I have read the documentation;
- In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.
- Ideally, I’m providing a sample JSFiddle or a shared playground link demonstrating the issue.
Description
For date form fields, I am using a regex pattern to validate that dates are of a specific format, such as the following:
"field":{
"title":"Date",
"type":"string",
"pattern":"^(([0][1-9]|[1-2][0-9]|[3][0-1])\.([0][1-9]|[1][0-2])\.((1[8,9][0-9][0-9])|(20[0-9][0-9])))$",
"validationMessage":"Date has to follow the format dd.mm.yyyy"
}
Some of my date fields should not accept a date that is either before or after a specific date. So I would like to also validate that the date is BeforeOrEqual or EqualOrAfter a specified date. In my use case, the date is always “today”.
I have managed to pass a min or max date option to a custom dateWidget, which greys out the unwanted dates (see screenshot), however the actual form field only validates using the pattern, which means that if a date is manually entered it only valides using the regex and not a min/max date.
Is it possible to supply a minimum or maximum date in any way using the form schema but not a pattern?
Screenshot attached.
Version
1.8.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
@iwan-uschka there was no response, assumed the custom widget mentioned above solved the problem. will re open
Hello @Wmarie, I have the same problem. I need to disable the past dates from today. Do you have something for fixing?