I'm using bootstrap datepicker in format mm/yyyy, but I can't set max month. My code is like this:
$('#mesVigencia').datepicker({
format: "mm/yyyy",
startView: "months",
minViewMode: "months",
language: 'pt-BR'
});
How can I set max month like current month?
Use maxDate:
in the object
$('#mesVigencia').datepicker({
format: "mm/yyyy",
startView: "months",
minViewMode: "months",
language: 'pt-BR',
maxDate: new Date("2017-11-00")
});
Use new Date("2017-11-00")
if you want to set november as the max month
you need endDate: "0m"
check my sample,
$('#mesVigencia').datepicker({ format: "mm/yyyy", startView: "months", minViewMode: "months", language: 'pt-BR', endDate: "0m" });
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.css" rel="stylesheet"/> <div id="mesVigencia"></div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
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.