Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!