Input Date - Set invalid date to null instead of today's date

Posted by: itvendorinfo on 9 October 2019, 6:45 pm EST

    • Post Options:
    • Link

    Posted 9 October 2019, 6:45 pm EST

    hello there,

    I am trying to implement a feature that requires the user to enter a date range into two adjacent columns in a grid, so i need a startDate and endDate column. For that requirement I decided to use wijmo’s date input and create a custom editor with it. the idea is that I will set the startDate’s [max] = endDate and endDate’s [min] = startDate. It all works flawlessly if I use the calendar and click on a date. The problem comes if I type a date that is later then the max or earlier then the min date. In that situation the date input cancels the edit and sets today’s value in the field. This is problematic because the user might not realize that the date they entered changed to today’s date automatically, and ultimately submit valid, but wrong date range. What I would like to do is: if the date they manually enter is outside of the min-max range, set the field to empty (instead of today’s date). Can someone help with a suggestion of how I can make the date-input use null as default value.

    Thank you

  • Posted 10 October 2019, 12:45 am EST

    Hi,

    To achieve the desired behavior, you will need to handle the textChanged and the valueChanged of both the InputDate controls. In the textChanged event, you will need to store the current text of the control and in valueChanged event, you will need to check if the old text is same as the current text and set its value to null accordingly. Also, you will need to handle the isDroppedDownChanged event to check whether the date is typed or it is set using the mouse. Please refer to the sample below:

    https://stackblitz.com/edit/ckkyne-tatfdl

    Let us know if you have any additional queries.

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels