DatePicker Invalid date handling.

Hi,

I am using Ejs datepicker in my angular 8 project.

When we enter the invalid date, it automatically clears the field. I want to give message to the user at this event.

Can you please let me know on which event I can do it ?

Thanks & Regards,
Ankit Pathak

1 Reply

SN Sevvandhi Nagulan Syncfusion Team April 6, 2020 10:45 AM UTC

Hi Ankit, 

Greetings from Syncfusion support. 

We have checked the reported requirement. We suspect that, you have enabled the strictMode for DatePicker component. If you enabled the strictMode, when enter the invalid date then input element will be cleared.   


And in the strictMode the error class will not be added when you choose the invalid date.  But, in the normal mode the error class will be added to the wrapper of the component  if you enter the invalid date.  So we suggest to disable the strictMode, and display the error message using the e-error class. In the blur event, we can clear the input element value If the date is invalid. Kindly refer the below code, 

    }; 
     onBlur(e){ 
    if(e.model.inputWrapper.container.classList.contains('e-error')){ 
      e.model.inputElement.value = null; 
      document.getElementById('errorMessage').style.display = "block"; 
      document.getElementById('errorMessage').innerText = "Invalid Date"; 
    } 
    else { 
      document.getElementById('errorMessage').style.display = "none"; 
    } 
  } 


Please find the sample below, 


Regards, 
Sevvandhi N 


Loader.
Up arrow icon