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

159
Views
Selector de fechas de JavaScript para el sistema de reservas

Estoy trabajando en un sitio web similar a un sistema de reserva de hotel. Los usuarios pueden reservar una habitación utilizando el sitio web.

Estas son las fechas no disponibles:

['2021-11-17', '2021-11-18', '2021-11-19', '2021-11-20', '2021-11-27', '2021-11-28']

En mi selector de fecha, deseo hacer esto:

  1. Solo fechas futuras y la fecha de salida no debe ser anterior a la fecha de entrada
  2. Para atenuar las fechas no disponibles para que los usuarios no puedan elegirlas
  3. Si el usuario elige hacer el check-in el 11-11-2021, la opción de check-out va hasta el 16-11-2021

Mi JS actual:

 const dateCheck = ['2021-11-17', '2021-11-18', '2021-11-19', '2021-11-20', '2021-11-27', '2021-11-28'] function disableDates(date) { var string = jQuery.datepicker.formatDate("yy-mm-dd", date); return [dateCheck.indexOf(string) == -1] } $("#listingCheckIn").datepicker({ beforeShowDay: disableDates, minDate: 0, dateFormat: "yy-mm-dd", showOn: "both", //upon selection onSelect: function(dateText, inst) { $("#listingCheckOut").datepicker("option", "minDate", $("#listingCheckIn").datepicker("getDate")); //2nd datepicker to set min value for 1st datepicker } }); $("#listingCheckOut").datepicker({ beforeShowDay: disableDates, minDate: 0, dateFormat: "yy-mm-dd", onSelect: function(dateText, inst) { $("#listingCheckOut").datepicker("option", "minDate", $("#listingCheckIn").datepicker("getDate")); //2nd datepicker to set min value for 1st datepicker } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.13.0/jquery-ui.min.js"></script> <form action="booking.php" id="bookingForm" method="post"> <div id="C_rightColumn"> <div class="C_rcTopBox flex-cc"> Rates </div> <div class="C_rcTopBox flex-cc"> <label>Check-In Date</label> <input type="text" id="listingCheckIn" name="checkin" class="date"> </div> <div class="C_rcTopBox flex-cc"> <label>Check-Out Date</label> <input type="text" id="listingCheckOut" name="checkout" class="date"> </div> <div class="C_rcBtmBox"> <button type="submit" class="btn" name="bookProperty">Book Now!</button> </div> </div> </form>

Básicamente, 1 y 2 es una oportunidad, pero ¿cómo logro 3 para que un usuario deba realizar el check-out antes del check-in de otras reservas? Gracias por adelantado.

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!