2010-09-14 15 views

risposta

15

beforeShowDay viene chiamato per ogni data visualizzata sulla calandra. Quando viene chiamato beforeShowDay, è necessario determinare se la data passata è l'ultimo giorno del mese.

Il seguente JScript restituirà l'ultimo giorno del mese per un determinato anno e mese.

function LastDayOfMonth(Year, Month) 
{ 
    return(new Date((new Date(Year, Month+1,1))-1)).getDate(); 
} 

Utilizzare il seguente codice per determinare se la data del beforeShowDay è l'ultimo del mese:

$('.selector').datepicker({ 
    beforeShowDay: function (date) { 
     //getDate() returns the day (0-31) 
     if (date.getDate() == LastDayOfMonth(date.getFullYear(),date.getMonth())) { 
      return [true, '']; 
     } 
     return [false, '']; 
    } 
}); 
+0

dispiace, ma il ritorno di ritorno linea di [falsa, '']; - mi mostra l'errore di sintassi –

+1

@ MArcin: è possibile rimuovere 1 ritorno da quella linea. – understack

1
function LastDayOfMonth(Year, Month) { 
    //set next month first day 
    //substract one day from it.   
    return new Date(new Date(Year, Month+1,1)-1).getDate(); 
} 

questo funzionerà

Problemi correlati