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

320
Vistas
jQuery Date Picker: bloquea un rango de fechas futuras

Tengo jQuery Date Picker en una tienda Shopify y he tenido algunos problemas al tratar de bloquear el próximo rango de fechas del 24/12/2021 al 04/01/202 DD MM YY, no estaremos operando en estos días.

Cualquier consejo sería muy apreciado, este es el script que estamos usando actualmente.

 $(document).ready( function() { $(function() { $("#date").datepicker( { firstDay: 1, minDate: +0, maxDate: '+2M', dateFormat: 'DD d MM yy' , beforeShowDay: $.datepicker.noWeekends, beforeShow : function(){ var dateTime = new Date(); var hour = dateTime.getHours(); if(hour>=10){ $(this).datepicker( "option", "minDate", "+1" ); } } } ); }); $('input[name="checkout"], input[name="goto_pp"], input[name="goto_gc"]').click(function() { if ($('#date').val() == "" || $('#date').val() === undefined) { alert("You must pick a delivery date"); return false; } else { //$(this).submit(); return true; } }); });
 <link rel="stylesheet" href="https:////code.jquery.com/ui/1.13.0/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.0/jquery-ui.js"></script> <input type="text" id="date">

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

0

Debe usar beforeShowDay y verificar qué fecha necesita mostrar sin días de fin de semana.

Comenté mi código a continuación.

 $(document).ready( function() { $(function() { $("#date").datepicker({ firstDay: 1, minDate: +0, maxDate: '+2M', dateFormat: 'DD d MM yy', beforeShowDay: function(date){ var noWeekend = $.datepicker.noWeekends(date); // we check if its not a weekend day if (noWeekend[0]) { // show days from range let val = new Date("2021-12-24") >= date || new Date("2022-01-04") < date; return [val]; } else { // else use function noWeekend return noWeekend; } }, beforeShow : function(){ var dateTime = new Date(); var hour = dateTime.getHours(); if (hour >= 10) { $(this).datepicker( "option", "minDate", "+1" ); } } }); }); $('input[name="checkout"], input[name="goto_pp"], input[name="goto_gc"]').click(function() { if ($('#date').val() == "" || $('#date').val() === undefined) { alert("You must pick a delivery date"); return false; } else { //$(this).submit(); return true; } }); });
 <link rel="stylesheet" href="https:////code.jquery.com/ui/1.13.0/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.0/jquery-ui.js"></script> <input type="text" id="date">

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