我正在使用 Bootstrap 多选日期选择器
HTML5:
<div class="form-group ">
<label for="unavailable_date" class="control-label col-lg-2" >unavailable date list</label>
<div class="col-lg-10">
<input type="text" id="unavailable_date" class="form-control date" placeholder="unavailable date list">
</div>
</div>
JS
$('.date').datepicker({
multidate: true,
format: 'dd-mm-yyyy'
});
每当我单击提交按钮时,验证消息就会出现并中断该过程,我如何禁用此元素的验证?
最佳答案
$('.date').datepicker({
multidate: true,
format: 'dd-mm-yyyy'
});
$('#onSubmit').click(function(){
var selectDate = $("#unavailable_date").val();
console.log(selectDate);
});
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
</head>
<body>
<div class="form-group ">
<label for="unavailable_date" class="control-label col-lg-2" >unavailable date list</label>
<div class="col-lg-10">
<input type="text" id="unavailable_date" class="form-control date" placeholder="unavailable date list">
</div>
</div>
<div class="form-group">
<button id="onSubmit" class="btn btn-primary" >Submit</button>
</div>
</body>
</html>
你可以试试这个
关于javascript - Bootstrap datepicker多个日期选择器不断返回 "Please enter a valid date.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57511172/