我正在开发 MVC 项目,我想使用日期选择器弹出日历。但它没有用。这是我的代码:
<script>
$(document).ready(function () {
$('#datetimepicker').datetimepicker({
yearOffset: -15,
lang: 'en',
timepicker: false,
format: 'm/d/Y',
formatDate: 'Y/m/d',
// minDate: '1940/01/02', // yesterday is minimum date
// maxDate: '2000/01/02' // and tommorow is maximum date calendar
});
});
</script>
查看
<div class="col-md-3">
<label class="control-label" style="font-family:Arial, Helvetica, sans-serif; font-size:13px;margin-top:6px;">
Date Of Birth<b style=" color:#ff0000;">*</b>
</label>
</div>
<div class="col-md-3" style="left:-25px;">
@Html.TextBoxFor(a => a.DOB, new { Class = "form-control ", placeholder = "Date of Birth", id = "datetimepicker", TextMode = "date", value = "01/11/1989", maxlength = "20", style = "width:175px;height:25px;font-size:small;" })
@Html.ValidationMessageFor(a => a.DOB)
</div>
答案 0 :(得分:3)
我认为您的问题是.NET MVC Helper方法将输入文本的 id 属性替换为可以跟踪其内部工作的内容。
您可以在HTML.idFor(f=> f.DOB);
行中$('#datetimepicker')...
获取目标 ID 。