I'm using jQuery date picker in my php site. It's working properly, but I want to disable previous date from it. I try to do in some ways but it's not working.
My script as follow
<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>
My form as follow. I'm using codeigniter in this project:
<?php
$data = array(
"name" => "edate",
"id" => "edate",
"value" => "",
"class" => "form-control",
"placeholder" => "Expire Date",
"aria-describedby" => "sizing-addon1"
);
echo form_input($data);
?>
When I click on this texbox calender is popup successfully. but I want to disable previous dates from it.
Try this:
window.onload = function() {
new JsDatePick({
useMode: 2,
target: "edate",
dateFormat: "%Y-%m-%d",
yearsRange:[y,9999],
minDate: 0 // Disable previous date
});
Try this Code For That, replace your codeigniter code with,
<?php
$data = array(
"name" => "edate",
"id" => "edate",
"value" => "",
"class" => "form-control input-datepicker",
"placeholder" => "Expire Date",
"aria-describedby" => "sizing-addon1"
);
echo form_input($data);
?>
and add This to your jquery,
$("#edate").datepicker({
startDate: '1'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.