简体   繁体   中英

Jquery datepicker selected date not assigning the value

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.

Try using

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

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

要为日期选择器分配一个值,您应该向其中发送一个“更新”操作:

$my_input.datepicker('update', new Date(my_date))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM