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

133
Visualizações
How do i change my start date and end date of my Calendar widget in JS?

I would like to know how do I change the start and end date of my calendar widget.

The date of the calendar should start at 1 January 2021 and I should be able to go until the Year 2030

At the moment I can go further than 2030 but I want it to stop at 2030.

    function createEventListeners() {
      var dateField = document.getElementById("tripDate");
      if (dateField.addEventListener) {
        dateField.addEventListener("click", displayCalendar, false);
      } else if (dateField.attachEvent) {
        dateField.attachEvent("onclick", displayCalendar);
      }

      var dateCells = document.getElementsByTagName("td");
      if (dateCells[0].addEventListener) {
        for (var i = 0; i < dateCells.length; i++) {
          dateCells[i].addEventListener("click", selectDate, false);
        }
      } else if (dateCells[0].attachEvent) {
        for (var i = 0; i < dateCells.length; i++) {
          dateCells[i].attachEvent("onclick", selectDate);
        }
      }

      var closeButton = document.getElementById("close");
      if (closeButton.addEventListener) {
        closeButton.addEventListener("click", hideCalendar, false);
      } else if (closeButton.attachEvent) {
        closeButton.attachEvent("onclick", hideCalendar);
      }

      var prevLink = document.getElementById("prev");
      var nextLink = document.getElementById("next");
      if (prevLink.addEventListener) {
        prevLink.addEventListener("click", prevMo, false);
        nextLink.addEventListener("click", nextMo, false);
      } else if (prevLink.attachEvent) {
        prevLink.attachEvent("onclick", prevMo);
        nextLink.attachEvent("onclick", nextMo);
      }
    }

    if (window.addEventListener) {
      window.addEventListener("load", createEventListeners, false);
    } else if (window.attachEvent) {
      window.attachEvent("onload", createEventListeners);
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use the following code. Set your date first in a variable and then assign max or min date.

var today="*date*"
document.getElementById("datefield").setAttribute("max", today);
about 4 years ago · Juan Pablo Isaza 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