Bootstrap Datepicker in mm/yyyy format set maximum date

Asked

Viewed 885 times

2

I’m using Bootstrap Datepicker in mm/yyyy format, but I’m having trouble defining the longest possible date.

inserir a descrição da imagem aqui

The Code is like this:

$('#mesVigencia').datepicker({
    format: "mm/yyyy",
    startView: "months",
    minViewMode: "months",
    language: 'pt-BR'
})



How to set the current month to be the largest month selectable?

1 answer

1


The maximum becomes today.

$( "#mesVigencia" ).datepicker({
    maxDate: "+0m +0w"
});

Or

$( "#mesVigencia" ).datepicker( "option", "maxDate", "+0m +0w" );

UPDATE

Tries to define as var.

var date2 = new Date();

date2.setDate(date2.getDate());

maxDate:date2
  • It didn’t work, I still manage to select future months.

  • I updated the answer, try again. Try to see the console if you have any js error.

  • Dude, it didn’t work either, and there are no errors in the console. I’ve tried several tips I found here in the OS and none worked so far.

  • Try to set with var then.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.