Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
How to disable calendar from been selected in HTML

I have an HTML <input /> with type=date and I'm trying to use javascript to disable an array of dates but for some reason, it is not working and not sure where I got it wrong, below is my code:

var array = ["2022-08-25", "2022-08-22", "2022-08-21"]

$('input[type="date"][name="tester"]').datepicker({
  beforeShowDay: function(date) {
    var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
    return [array.indexOf(string) == -1]
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script   src="https://code.jquery.com/ui/1.13.1/jquery-ui.min.js"   integrity="sha256-eTyxS0rkjpLEo16uXTS0uVCS4815lc40K2iVpWDvdSY="   crossorigin="anonymous"></script>
<input type="date" name="tester">

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Creating a datepicker on an <input type="date"> is not supported due to a UI conflict with the native picker.

See more: https://api.jqueryui.com/datepicker/

Consider the following.

var array = ["2022-08-25", "2022-08-22", "2022-08-21"]

$('input[name="tester"]').datepicker({
  beforeShowDay: function(date) {
    var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
    return [array.indexOf(string) === -1]
  }
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<input type="text" name="tester">

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda