Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1490
2 scenarios where minValue on datePicker acts a little odd
posted

There are 2 scenarios where the minValue on the igDatePicker control doesn't work exactly like I would expect it to. I've set the min date on the control to 1/1/1753. 

1) If I enter 01/01/0001, the control changes date to 1/1/2001, but I would expect it to change it to 1/1/1753.

2) If I enter 00/00/0000, the control blanks the date out completely, but I would expect it to change it to 1/1/1753. 

I've attached a sample that you can for both of these scenarios and see the results.

min dates.zip
  • 1905
    posted

    Hello Ryan,

    Thank you for posting in the Infragistics Community.  I will be happy to help you with your inquiry.

    I have investigated the behavior you reported regarding the igDatePicker and was able to reproduce the results you described.  My team and I want to further look into the cause of this behavior to gain a better understanding of what is happening.  I will be sure to update you with more information as my team confirms findings and discovers a fix. 

    In the meantime, I do have a workaround which I would suggest which would give you consistency for invalid values.  This can be done through the use of an invalidValue event.  An example of manually setting the date to the minimum value can be seen in the below code snippet:

    Code Snippet
    1.     <script>
    2.         $(function () {
    3.  
    4.             $("#datePicker").igDatePicker({
    5.                 minValue: new Date(1753, 4, 4),
    6.                 nullable: false,
    7.                 invalidValue: function (evt, ui) {
    8.                     if (ui.year < 1753) {
    9.                         ui.value = new Date(1752, 12, 1);
    10.                     }
    11.                 }
    12.             });
    13.  
    14.         });
    15. </script>

    With the invalidValue function, you can check to see if the date is before your earliest value, and if so, manually reset it to whatever you date you want by resetting ui.value.  You will note that the date is set to a month earlier than the date desired.  This is because the igDatePicker automatically increments the month. 

    I hope this helps solve your problem.  I will keep you updated with any new developments in the issue.  Please let me know if there is anything else I can help you with.