当用户在下面的HTML代码中选择日期时
<div class="form-group">
@Html.LabelFor(model => model.PPEDueDate, "PPE Due Date", new { @class = "control-label col-md-5" })
<div class="col-md-offset-0">
@Html.TextBoxFor(model => model.PPEDueDate, new { @class = "datepicker5", id = "datepicker5" })
@Html.ValidationMessageFor(model => model.PPEDueDate)
</div>
</div>
然后,下面的字段也应自动填充。
<div class="form-group">
@Html.LabelFor(model => model.PPET_PPEDueDate, "PPE Due Date", new { @class = "control-label col-md-5" })
<div class="col-md-offset-0">
@Html.TextBoxFor(model => model.PPET_PPEDueDate, new { @class = "datepicker28", id = "datepicker28" })
@Html.ValidationMessageFor(model => model.PPET_PPEDueDate)
</div>
</div>
我的日期选择器由填充
<script>
$(function () {
$("#datepicker5").datepicker({ dateFormat: "dd-mm-yy", changeMonth: true, changeYear: true });
$("#datepicker28").datepicker({ dateFormat: "dd-mm-yy", changeMonth: true, changeYear: true });
});
</script>
您可以使用以下代码通过JQuery将值从第一个日期选择器复制到第二个日期选择器:
$('#datepicker5').datepicker({
onSelect: function(dateText) {
$('#datepicker28').val(dateText);
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句