We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ejDatePicker is not a function

Hello,

I am using the Javascript DatePicker control.  I need to get the value of the control in javascript. The control displays fine and I can select a date, but when I run this line

var dateObj = $('#testinput').ejDatePicker("instance");

I get

Uncaught TypeError: $(...).ejDatePicker is not a function

Is this the correct call to get the selected date value?  If not, what should I be using?  I have tried everything I can think of but I still get the same error


JSFiddle here:


   








3 Replies

SP Sureshkumar P Syncfusion Team October 29, 2019 09:42 AM UTC

Hi Jim, 
 
Greetings from Syncfusion support. 
 
We validated your requirement with shared code. We can get our instance using ej2_instances[0] method. Kindly refer the below code block. 
 
document.getElementById('btn').onclick = function () { 
    var dateObj = document.getElementById('datepicker').ej2_instances[0]; 
    console.log(dateObj); 
} 
 
 
We created s sample based on your requirement. please refer the sample: https://stackblitz.com/edit/p7gcce?file=index.js  
 
Regards, 
Sureshkumar P 



JO Jim Oliver October 29, 2019 03:14 PM UTC

Yep, that works!

Can I suggest that you add this to the documentation?  Date pickers are great and all, but it there is no documentation for getting the data out of them they aren't much use.

thanks again!




SP Sureshkumar P Syncfusion Team October 30, 2019 07:03 AM UTC

Hi Jim, 
 
Thanks for your update. We will consider this in our documentation section. 
 
Regards, 
Sureshkumar P 


Loader.
Live Chat Icon For mobile
Up arrow icon