我需要在EditorFor字段上使用datepicker.
我的视图代码是:
<div class="editor-label">
@Html.Label("birthDate","birthDate")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.birthDate, new { @class = "datepicker"})
@Html.ValidationMessageFor(model => model.birthDate)
</div>
Run Code Online (Sandbox Code Playgroud)
剧本:
<script type="text/javascript">
$(document).ready(
function () {
$('.datepicker').datepicker({
changeMonth: true,
changeYear: true,
minDate: "-99Y",
dateFormat: "dd/mm/yyyy"
});
});
Run Code Online (Sandbox Code Playgroud)
我不能让它发挥作用.我有以下错误:Microsoft JScript运行时错误:对象不支持此属性或方法'datepicker'.
我在尝试调用函数之前已经加载了jQuery.