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

299
Vistas
Why is the input type "date" value not updating new values from the input

I am trying to get a date from the input type "date" but when I retrieve the data in JavaScript, only the default value that I set is retrieved all the time.

No matter what I do, I keep getting the default value instead of the new one I chose.

I couldn't find any solution from all the similar questions about this, please do not flag this question because I am already getting a warning that my last question was not well received by the community, I thought we are here to learn and asking stupid questions is part of it.

var getInput = document.querySelector("#year");
var data = getInput.value, dob = data.split("-"), byy = dob[0], bmm = dob[1], bdd = dob[2];

function process(){
console.log(byy)
}
<input id="year" type="date" value="2022-12-25" required><br>
<input id="goBtn" onclick="process()" type="button" value="Go">

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Get the date value within the function you are calling.

function process() {
  var getInput = document.querySelector("#year");
  var data = getInput.value, dob = data.split("-"), byy = dob[0], bmm = dob[1], bdd = dob[2];
  console.log(byy);
}
<input id="year" type="date" value="2022-12-25" required><br>
<input id="goBtn" onclick="process()" type="button" value="Go">

The variables were being assigned to immediately when the JavaScript executed, giving them the default value. They need to be assigned to at the time you press the go button.

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