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

189
Vistas
DatePicker onClose returns undefined value

I have an issue with jquery datepicker in materialize, it always returns an undefined value in the onClose function:

<input type="text" class="datepicker">

...


$('.datepicker').datepicker({ 
  format: 'yyyy-mm-dd',
  firstDay: 1,
  minDate: new Date(),
  autoClose: true,
  onClose: function (date, datepicker) {
    alert("Selected Date: " + date);
  }
});

date is always undefined - but the input field is correctly filled with the date, e.g. 2022-05-16

Did I do something wrong? How can I get the value?

The input field does not have an ID, because it is created dynamically.

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

0

I reproduced your snippet, and as you can see it works fine, as long as you are not able to reproduce the issue it will be impossible to help you further.

$('.datepicker').datepicker({
  format: 'yyyy-mm-dd',
  firstDay: 1,
  minDate: new Date(),
  autoClose: true,
  onClose: function(date, datepicker) {
    alert("Selected Date: " + date);
  }
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/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.1/jquery-ui.js"></script>

<input type="text" class="datepicker">

about 4 years ago · Juan Pablo Isaza Denunciar

0

Works for me:

$('.datepicker').datepicker({ 
  format: 'yyyy-mm-dd',
  firstDay: 1,
  minDate: new Date(),
  autoClose: true,
  onClose: function (date, datepicker) {
    alert("Selected Date: " + date);
  }
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<input type="text" class="datepicker">

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