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

92
Views
How can I make first date max of second date

I would like to run this code but without success. I'm a beginner please! Indeed, I have two dates date1 and date2. and I would like after selecting date date1 that date to be the max date of date date2. I tried with it but it does not work (Onchange)

$(document).ready(function() {

  // Date1

  $(".date1").datepicker({
    todayBtn: 1,
    autoclose: true,
  }).on('changeDate', function(selected) {
    var minDate = new Date(selected.date.valueOf());
    $('.date2').datepicker('setStartDate', minDate);

  });

  // Date2

  $(".date2").datepicker({
    todayBtn: 1,
    autoclose: true,
  }).on('changeDate', function(selected) {
    var minDate = new Date(selected.date.valueOf());
    $('.date1').datepicker('setStartDate', minDate);

  });

});
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

<p>Date: <input type="text" class="date1"></p>

<p>Date: <input type="text" class="date2"></p>

about 4 years ago · Juan Pablo Isaza
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!