Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda