Jquery datepicker selected date not assigning the value

半城伤御伤魂 提交于 2019-12-25 08:00:10

问题


I have a date picker associated with an editor field for selecting the date. But when i select the date, the selection is showing in the editor field but the value is not getting assigned to the respective element.

My code is as follows:

jQuery:

$("#JobDate").click(function () {
    $(this).datepicker({ dateFormat: 'dd/mm/yy' }).datepicker("show");
});

cshtml code

<tr class="spaceUnder">
    <td>@Html.LabelFor(model => model.JobDate)</td>
    <td>@Html.EditorFor(model => model.JobDate)</td>
</tr>

I would also like to hear your approach on this one. Alternative methods are also welcome.


回答1:


Try using

$('#JobDate").datepicker({
    //your configuration here
});

This assigns handlers to handle setting the value of your input when you select a date.



来源:https://stackoverflow.com/questions/40309366/jquery-datepicker-selected-date-not-assigning-the-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!