我正在使用Bootstrap DateTime控件,无法验证
的日期
“ 最大日期是今天”
HTML代码
<div class="col-md-3">
<div id="datepicker-popup" class="input-group date datepicker">
@Html.TextBoxFor(model => model.FromDate, new { @class = "form-control" , @placeholder = "dd/MM/yyyy", @autocomplete = "off", @readonly = "readonly" })
<span class="input-group-addon input-group-append border-left">
<span class="mdi mdi-calendar input-group-text"></span>
</span>
</div>
</div>
jQuery代码
$('#FromDate').datepicker({
format: 'mm-dd-yyyy',
autoclose: true,
maxDate: new Date()
});
我找不到我做错了什么,请让我知道 解决方案。
谢谢
答案 0 :(得分:1)
可能存在许多不同版本的引导日期选择器。
我尝试了一个使用datetimepicker
而不是datepicker
的示例。
$('#FromDate').datetimepicker({
format: 'mm-dd-yyyy',
maxDate: 'now'
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<div class="col-md-3">
<div id="datepicker-popup" class="input-group date datepicker">
<input type="text" class="form-control" id="FromDate" />
<span class="input-group-addon input-group-append border-left">
<span class="mdi mdi-calendar input-group-text"></span>
</span>
</div>
</div>