Si queremos habilitar sólo el último día de cada mes podemos añadir este script en el head de nuestra página web:
$(function() { $( "#datepicker" ).datepicker(); }); function LastDayOfMonth(Year, Month) { return(new Date((new Date(Year, Month+1,1))-1)).getDate(); } $(function() { $('#txtDate').datepicker({ beforeShowDay: function (date) { //getDate() returns the day (0-31) if (date.getDate() == LastDayOfMonth(date.getFullYear(),date.getMonth())) { return [true, '']; } return [false, '']; } }); });
Con lo que tendríamos lo siguiente para el mes de Septiembre de 2015:
El código completo para que funcione en un archivo .html sería el siguiente:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Datepicker - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() { $( "#datepicker" ).datepicker(); }); function LastDayOfMonth(Year, Month) { return(new Date((new Date(Year, Month+1,1))-1)).getDate(); } $(function() { $('#txtDate').datepicker({ beforeShowDay: function (date) { //getDate() returns the day (0-31) if (date.getDate() == LastDayOfMonth(date.getFullYear(),date.getMonth())) { return [true, '']; } return [false, '']; } }); }); </script> </head> <body> Fecha: <input type='text' id='txtDate' /> </body> </html>
Excelente!, muchas gracias!