How to clear selected date from javascript

i need to clear/reset date on a certain condition using javascript. how do i accomplish that?
{
  var datepickerObject = document.getElementById("date").ej2_instances[0];
                        datepickerObject.properties = {
                            format: "dd/MM/yyyy",
                            max: new Date(),
                            min: new Date(),
                            placeholder: "Choose a Date",


                        }                           


3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team December 21, 2020 10:37 AM UTC

Hi Shahzaib,  

Greetings from Syncfusion support.  

Query: I need to clear/reset date on a certain condition using Javascript. how do i accomplish that? 
  
You can clear/Reset the date using Javascript as like below code snippet. We have prepared sample by clear the date in button click. Here we have attached the sample for your reference. 

    <script> 
        document.getElementById("dynamic").onclick = function () { 
            var datepickerObject = document.getElementById("date").ej2_instances[0]; 
            //Clear date 
            datepickerObject.value = null; 
 
            //Rest date 
            //datepickerObject.value = "17/11/2020"; 
        } 
    </script> 


Kindly check with the above sample. Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer

SH shahzaib December 22, 2020 05:03 AM UTC

thanks its working fine now


PM Ponmani Murugaiyan Syncfusion Team December 22, 2020 05:20 AM UTC

Hi Shahzaib, 

We are glad to hear that the provided solution helps you to achieve your requirement. Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Loader.
Up arrow icon