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

How to write select function in datepicker

Hi,

I have Datepicker in ejs.I need to get data based on selected date. onChange is also not working for me.How to get value on selection of date.

<ejs-datepicker floatLabelType="Auto" ejs-for="@Model.Calender" id="Calender" value="@Model.Calender" name="calender" content="@(Localizer["Calender"].Value)" placeholder="@Html.DisplayNameFor(m=>m.Calender)"></ejs-datepicker>

3 Replies

SP Sureshkumar P Syncfusion Team November 12, 2019 10:49 AM UTC

Hi Krishna, 
 
Greetings from Syncfusion support. 
 
With shared code, we have validated your query and suspect that your sample does not properly bind our change event as shown in our sample code below. We would like to suggest the datepickerFor control which doesn’t need to attach the name attribute. We set the attribute of the name based on the value of the binding model. 
 
Kindly refer to the below code block 
 
@model Syncfusion_EJ2_Core_App.Controllers.dateValue 
<form method="post"> 
    <ejs-datepicker floatLabelType="Auto" ejs-for="@Model.Calender" id="Calender" value="@Model.Calender" 
        name="calender" placeholder="@Html.DisplayNameFor(m=>m.Calender)" change="OnChange"></ejs-datepicker> 
    <button id="submit">Submit</button> 
</form> 
<script> 
    function OnChange(args) { 
        alert(args.value); 
    } 
</script> 
 
We have created a sample based on your requirement. Please find the sample here: https://www.syncfusion.com/downloads/support/forum/148991/ze/Syncfusion_EJ2_Core_App_148991-1121203544  
 
Regards, 
Sureshkumar P 



AB Alan Baljeu February 14, 2020 10:33 PM UTC

I find that when I click the dropdown button, onChange is firing already.  I need onChange to happen only when I click a date.


SP Sureshkumar P Syncfusion Team February 17, 2020 01:41 PM UTC

Hi Alan, 
 
We have validated your requirement. we cannot reproduce the reported issue. In our datepicker the change event will trigger while selecting the date value in the calendar. Please check the below video demonstration. 
 
 
Regards, 
Sureshkumar P 


Loader.
Live Chat Icon For mobile
Up arrow icon