问题
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