[英]How to prevent users from choosing a date greater than today?
Currently, users can choose any date even greater than today to register a patient.目前,用户可以选择比今天更大的任何日期来注册患者。 They are supposed to be able to register the patient into the system who had their treatment few days back but not for upcoming treatment.他们应该能够将几天前接受过治疗但不能接受即将接受治疗的患者登记到系统中。 In short, I wish to disable the users from choosing a date greater than today.简而言之,我希望禁止用户选择大于今天的日期。 So, here's what I have :所以,这就是我所拥有的:
$(document).ready(function(){
$('.datefield').datetimepicker({ 'dateFormat': 'dd-mm-yy' });
$("#register_date").val( $dss.getDate("dd-mm-yyyy jj:nn") )
if ($("#cancel_date").val() == "" ){ //00-00-0000 00:00
$("#cancel_date").val( $dss.getDate("dd-mm-yyyy jj:nn") )
}
user_name = "<?php echo $_SESSION['USER_NAME']; ?>"
user_id = "<?php echo $_SESSION['USER_ID']; ?>"
ipdMC();
$("#cancel_id").val(user_id);
///--> getLabStatus();
physio_list_start();
$$live();
});
and this as my reference :这作为我的参考:
*$(document).ready(function (){
var todaysDate = new Date(); // Gets today's date
// Max date attribute is in "YYYY-MM-DD". Need to format today's date accordingly
var year = todaysDate.getFullYear(); // YYYY
var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2); // MM
var day = ("0" + todaysDate.getDate()).slice(-2); // DD
var maxDate = (day +"-"+ month +"-"+ year); // Results in "YYYY-MM-DD" for today's date
// Now to set the max date value for the calendar to be today's date
$('.inspectionDate input').attr('max',maxDate);
});*
you can use mindate to make the datetimepicker disabled to the date greater than today您可以使用 mindate 将 datetimepicker 禁用到大于今天的日期
$(document).ready(function(){
$('.datefield').datetimepicker({
'dateFormat': 'dd-mm-yy',
'maxDate': 0
});
$("#register_date").val( $dss.getDate("dd-mm-yyyy jj:nn") )
if ($("#cancel_date").val() == "" ){ //00-00-0000 00:00
$("#cancel_date").val( $dss.getDate("dd-mm-yyyy jj:nn") )
}
user_name = "<?php echo $_SESSION['USER_NAME']; ?>"
user_id = "<?php echo $_SESSION['USER_ID']; ?>"
ipdMC();
$("#cancel_id").val(user_id);
///--> getLabStatus();
physio_list_start();
$$live();
});
but make if you use javascript your timezone will be using client side timezone so be careful但是如果你使用 javascript 你的时区将使用客户端时区所以要小心
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.