gpt4 book ai didi

javascript - 选择今天之前的日期并禁用 CodeIgniter 中的所有 future 日期

转载 作者:行者123 更新时间:2023-11-28 05:38:41 24 4
gpt4 key购买 nike

如何在 CodeIgniter View 中启用从今天开始的前几天的选择并禁用 future 的日期?现在我的代码显示所有 future 的日期并禁用所有以前的日期。我的代码如下:

<script>
var elem = document.getElementById("security_question_1");

elem.onchange = function() {
var hiddenDiv = document.getElementById("showMe");
hiddenDiv.style.display = (this.value == "Absconding") ? "none":"none";
hiddenDiv.style.display = (this.value == "Termination") ? "none":"block";
hiddenDiv.style.display = (this.value == "Employee Initiated") ? "none":"block";
};

function parseDate(str) {
var mdy = str.split('/')
return new Date(mdy[2], mdy[0]-1, mdy[1]);
}

function daydiff(first, second) {
return Math.round((second-first)/(1000*60*60*24));
}

$(document).ready(function() {
$("#startdt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
startDate: new Date(),
autoclose: true
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddt').datepicker('setStartDate', minDate);
});

$("#sincedt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:-10",
startDate: new Date(),
autoclose: true
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddt').datepicker('setStartDate', minDate);
});

$("#enddt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0"
});

$("#enddtt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0"
});

$("#enddttt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0"
});

$("#enddt").change(function(){
if($("#startdt").val()!='' && $("#enddt").val()!='') {
var startdt = $("#startdt").val();
var enddt = $("#enddt").val();
$("#daysleave").val(daydiff(parseDate(startdt), parseDate(enddt)));
if($("#grievance_type").val()!='0') {
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));

if(((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max"))))&&(day_diff_today > parseInt($("#grievance_type option:selected").attr("data-approvaldays")))) {
} else {
$("#leaveAllowedModal").modal("show");
}
}
}
})

$("#grievance_type").change(function() {
if($("#startdt").val()!='' && $("#enddt").val()!='' && $("#grievance_type").val()!='0') {
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));

if(((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max"))))&&(day_diff_today > parseInt($("#grievance_type option:selected").attr("data-approvaldays")))) {
} else {
$("#leaveAllowedModal").modal("show");
}
}
})

$(".date-picker").datepicker();

$("#optionsRadios1").click(function() {
$("#myLTAModal").modal("show");
})

$('#leaveAllowedModal').on('shown.bs.modal', function() {
var msg = '';
if((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max")))) {
} else {
msg = msg + "You wish you apply "+$("#daysleave").val()+" day of "+$("#grievance_type option:selected").text()+". Minimum and Maximum no. of Leaves allowed to take at a time are "+$("#grievance_type option:selected").attr("data-min")+" and "+$("#grievance_type option:selected").attr("data-max")+" respectively.";
}
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));
if((day_diff_today < parseInt($("#grievance_type option:selected").attr("data-approvaldays")))) {
msg = msg + " No. of days of prior approval needed is " + $("#grievance_type option:selected").attr("data-approvaldays") + " days";
}
$(".allowed_text").html(msg);
})
});
</script>

我想在这里显示它:

<tr>
<td>
<label>Absconding Since</label>
</td>
<td>
<div class="date" data-date="12-02-2012" data-date-format="mm-dd-yyyy" data-date-viewmode="years">
<input placeholder="Absconding Since" class=" m-wrap col-md-8 form-control " id="startdt" type="text" name="abscondingsince" value="<?php if($row->requested_date!='') echo date("d-m-Y",$row->requested_date); ?>" required/>
</td>
</tr>

最佳答案

您是否尝试过使用 maxDate 而不是 minDate

关于javascript - 选择今天之前的日期并禁用 CodeIgniter 中的所有 future 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39122255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com