question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validation for max/min date

See original GitHub issue

Prerequisites

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. image

Version

1.8.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jacqueswhocommented, May 3, 2022

@iwan-uschka there was no response, assumed the custom widget mentioned above solved the problem. will re open

1reaction
laboratorioAIcommented, Nov 11, 2020

Hello @Wmarie, I have the same problem. I need to disable the past dates from today. Do you have something for fixing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation date input - min and max value - Stack Overflow
I have no idea how to parse the date object and check that is correct. Attribute min and max in HTML5 is not...
Read more >
Min / Max Date Validation and Compare Validation for Two ...
In some cases you want to have the end users select dates within given ranges and to ensure one date is before the...
Read more >
Javascript Date & Time Min & max values Example - Mobiscroll
Date & Time - Min & max values ; August. September. October. November. December ; 13. 14. 15. 16. 17 ; 1982. 1983....
Read more >
Validation Start/End Date with min and max amount of days ...
Hi there I am trying to implement a Validation rule that restricts the min and max amounts of days between a start and...
Read more >
Datepicker with min & max validation - StackBlitz
templateUrl: 'datepicker-min-max-example. html',. }) export class DatepickerMinMaxExample {. minDate: Date;. maxDate: Date;. constructor() {.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found