WjInputDate defaults to this.min when invalid date is entered

Posted by: tina.kujawa on 27 October 2025, 3:42 pm EST

  • Posted 27 October 2025, 3:42 pm EST

    We are using Wijmo : 5.20241.19. I have a date control that extends WjInputDate: MaskedDateComponent extends WjInputDate. I am having issues with the control trying to change what it thinks are invalid dates to this.min or this.max. I want to clear out the field if they enter a date not default it. Defaulting creates issues. How do I turn the defaulting off? I have added code to override _setText but there are still uses cases it does not catch.

  • Posted 28 October 2025, 3:02 am EST

    Hi Tina,

    You can override the ‘_clamp’ method of the InputDate’s calendar to control the auto-correction as per your needs. Please refer to the following sample demonstrating the same - https://stackblitz.com/edit/angular-yc9rpxek?file=src%2Fapp%2Fapp.component.ts

    In the above sample, we have overridden the ‘_clamp’ method to set a null value for the dates that are not in the min-max range.

    In case, you face any issues, please let us know.

    Regards

  • Posted 28 October 2025, 9:10 am EST - Updated 28 October 2025, 11:56 am EST

    Thanks - that is helpful. I am also noticing a couple other things:

    (1) it will automatically add a year if you type 0909 → it assumed 2025 and adds that when you leave the date control. Can we turn that off? We are trying to just clear bad dates and not make assumptions on what they meant.

    (2) I see it at time revert to the last good date when you lose focus. So if I enter a valid date, lose focus, then enter an invalid date, lose focus → it reverts to the first date I entered. How do i turn that off?

  • Posted 29 October 2025, 2:11 am EST

    Hi Tina,

    You’ll have to override the ‘_commitText’ method of the InputDate in that case. Please refer to the following updated sample demonstrating the same - https://stackblitz.com/edit/angular-ziwjaleb?file=src%2Fapp%2Fapp.component.ts

    In the above sample, we have just added basic checks for the date string validity, you can add more checks and validity criteria to validate the date strings as per your needs.

    The second issue you mentioned should be resolved by setting the ‘isRequired’ property of the InputDate to false, as it will allow setting null values to the input date control when focus is lost.

    In case, you face any issues, please let us know.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels