Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript EONASDAN日期选择器仅在更改时验证_Javascript_Asp.net_Datepicker - Fatal编程技术网

Javascript EONASDAN日期选择器仅在更改时验证

Javascript EONASDAN日期选择器仅在更改时验证,javascript,asp.net,datepicker,Javascript,Asp.net,Datepicker,我正在asp.net中实现eonasdan的日期选择器。SQL数据库中不需要VisitDate字段,因此如果需要,我希望允许用户将其保留为空。如果它不是空的,我想验证它。如果已输入,则验证它 一切正常,只是需要一个访问日期。如何允许访问日期为空 我尝试注释掉html.validationmessagefor,它会抑制该消息,但仍会阻止用户保存页面,直到选择了有效日期 从视图(.cshtml)中: @*----就诊日期----*@ @LabelFor(model=>model.VisitDate,

我正在asp.net中实现eonasdan的日期选择器。SQL数据库中不需要VisitDate字段,因此如果需要,我希望允许用户将其保留为空。如果它不是空的,我想验证它。如果已输入,则验证它

一切正常,只是需要一个访问日期。如何允许访问日期为空

我尝试注释掉html.validationmessagefor,它会抑制该消息,但仍会阻止用户保存页面,直到选择了有效日期

从视图(.cshtml)中:

@*----就诊日期----*@
@LabelFor(model=>model.VisitDate,htmlAttributes:new{@class=“control label”})
@EditorFor(model=>model.VisitDate,新建
{
HtmlatAttributes=新
{
@值=型号VisitDate.ToString(“MM/dd/yy”),
@class=“表单控制输入sm”
},
})
@Html.ValidationMessageFor(model=>model.VisitDate,“,new{@class=“text danger”})
我的javascript代码:

@section Scripts {

<script type="text/javascript">
  $(function () {
  $('#VisitDate').datetimepicker({
  defaultDate: '',  @*@Model.VisitDate*@
                    format: 'L',
                    showClose: true,
                    showClear: true,
                    toolbarPlacement: 'top',
                    useCurrent: false,
                    date: 'glyphicon glyphicon-calendar'
                });
     });
</script>

@Scripts.Render("~/bundles/jqueryval")

}
@节脚本{
$(函数(){
$(“#VisitDate”).datetimepicker({
defaultDate:“”,@*@Model.VisitDate*@
格式:“L”,
showClose:没错,
真的,,
工具栏位置:“顶部”,
useCurrent:false,
日期:“Glyphion日历”
});
});
@Scripts.Render(“~/bundles/jqueryval”)
}
@section Scripts {

<script type="text/javascript">
  $(function () {
  $('#VisitDate').datetimepicker({
  defaultDate: '',  @*@Model.VisitDate*@
                    format: 'L',
                    showClose: true,
                    showClear: true,
                    toolbarPlacement: 'top',
                    useCurrent: false,
                    date: 'glyphicon glyphicon-calendar'
                });
     });
</script>

@Scripts.Render("~/bundles/jqueryval")

}