我想结合两个数据交换条件来显示日期。
分开,它们就能工作。但是当我把它们结合在一起的时候,只有两个作品中的一个。我篡改了我的代码。这就是了。谢谢。
https://jsfiddle.net/y8ojanna/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div class="row">
<div class="col-md-2 col-sm-12 ">
<h3>Afhalen op:</h3>
</div>
<div class="col-md-4 col-sm-12 ">
<div id="date"></div>
<label>Geselecteerd:</label>
<input type="text" id="datefield" name="date" required data-readonly/>
</div>
</div>JAVASCRIPT
var selected;
$(function() {
var date = new Date();
var dayNo = date.getDay();
var mindate = (7-dayNo);
$( "#date" ).datepicker({
dateFormat: 'yy-mm-dd', firstDay: 1,minDate: mindate
});
$('#date').datepicker({beforeShowDay: function(date){
return [date.getDay() != 1 & date.getDay() != 2 & date.getDay() != 3 & date.getDay() != 5 & date.getDay() != 0, ''];
}});
$('#date').on("change",function(){
selected = $(this).val();
document.getElementById('datefield').value = selected;
});
});发布于 2017-04-24 08:55:42
下面的代码将做两件事:
var dateToday = new Date();
$('#visit').datepicker({
beforeShowDay: checkAvailable,
minDate: '+1w'
});
function checkAvailable(date) {
var day = date.getDay();
return [(day == 4 || day == 5)];
}<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link href="https://davidwalsh.name/demo/jquery-ui-css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet"/>
<input type='text' id='visit' />
我希望这就是你想要的:)
https://stackoverflow.com/questions/43583447
复制相似问题