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

877
Views
Deshabilite la fecha pasada en FullCalendar para dateClick

Aquellos que aún buscan una solución sobre cómo deshabilitar la fecha pasada, hagan clic en el evento Dateclick en FullCalendar. puede intentar ver la solución a continuación, si alguno de los lectores tuvo otra idea, puede publicar otra solución a continuación. Sería mucho mejor si hay otra manera fácil. Cuanta más solución, mejor sería.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Es posible mejorar su manipulación de cadenas de fechas, haciendo una comparación simple de la siguiente manera:

 dateClick: function (info) { var clickedDate = getDateWithoutTime(info.date); var nowDate = getDateWithoutTime(new Date()) if (clickedDate >= nowDate) alert("Future date"); else alert("Past date"); }

Es ayudado por esta función:

 //get date without the time of day function getDateWithoutTime(dt) { dt.setHours(0,0,0,0); return dt; }

Demostración: https://codepen.io/ADyson82/pen/ZErwJGx


Otra opción para lograr el mismo objetivo es usar la funcionalidad validRange . Esto le permite establecer dinámicamente una fecha de inicio, antes de la cual todas las fechas están deshabilitadas:

 validRange: function (nowDate) { return { start: nowDate }; },

Demostración: https://codepen.io/ADyson82/pen/VwQgWJO

Sin embargo, la pequeña desventaja de esto es que también oculta cualquier evento que ocurra antes de la fecha actual; es posible que no desee esto.


Por lo tanto, otra alternativa es usar selectAllow para restringir dónde puede seleccionar el usuario. Tenga en cuenta que esto depende de que use la devolución de llamada select en lugar de dateClick , pero eso no debería ser un gran problema.

 selectAllow: function (info) { return (info.start >= getDateWithoutTime(new Date())); }

Demostración: https://codepen.io/ADyson82/pen/VwQgzZJ

about 4 years ago · Santiago Gelvez Report

0

A continuación se muestra solo mi solución actual para deshabilitar la fecha pasada en FullCalendar. Cualquier idea o mejora sería apreciada para mejorar el código a continuación.

 dateClick: function(e) { // Get Today var dt = calendar.getDate(); var year = dt.getFullYear(); var month = dt.getMonth() + 1; var day = dt.getDate(); if(month < 9){ month = '0'+month; } if(day < 9){ day = '0'+day; } var today = year + '-' + month + '-' + day; // Get Selected Date var check = e.dateStr; let A = today.toString(); let B = check.toString(); alert('Date A: ' + A ); alert('Date B: ' + B ); if(B >= A){ alert('Past Date'); } else{ alert('Future Date'); } },
about 4 years ago · Santiago Gelvez 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!