我在我的php网站上使用jQuery日期选择器。它正常工作,但我想禁用它的前一个日期。我尝试在某些方面做但不起作用。
我的脚本如下
<link rel="stylesheet" type="text/css" media="all" href="<?php echo base_url("cal/jsDatePick_ltr.min.css"); ?>" />
<script type="text/javascript" src="<?php echo base_url("cal/jsDatePick.jquery.min.1.3.js"); ?>"></script>
<script type="text/javascript">
var today = new Date();
var y = today.getFullYear();
var m = today.getMonth();
var d=today.getDate();
window.onload = function() {
new JsDatePick({
useMode: 2,
target: "edate",
dateFormat: "%Y-%m-%d",
yearsRange:[y,9999]
});
};
</script>
我的表格如下。我在这个项目中使用了codeigniter:
<?php
$data = array(
"name" => "edate",
"id" => "edate",
"value" => "",
"class" => "form-control",
"placeholder" => "Expire Date",
"aria-describedby" => "sizing-addon1"
);
echo form_input($data);
?>
当我点击此texbox时,日历成功弹出。但我想禁用之前的日期。
答案 0 :(得分:0)
试试这个:
window.onload = function() {
new JsDatePick({
useMode: 2,
target: "edate",
dateFormat: "%Y-%m-%d",
yearsRange:[y,9999],
minDate: 0 // Disable previous date
});
答案 1 :(得分:0)
试试这个代码, 用,
替换你的codeigniter代码<?php
$data = array(
"name" => "edate",
"id" => "edate",
"value" => "",
"class" => "form-control input-datepicker",
"placeholder" => "Expire Date",
"aria-describedby" => "sizing-addon1"
);
echo form_input($data);
?>
并将此添加到您的jquery,
$("#edate").datepicker({
startDate: '1'
});