$(function() { $("#data_admissao, #data_demissao").datepicker({ dateFormat: "dd/mm/yy", showOn: "both", buttonImage: "img/calendar.gif", buttonImageOnly: true }); //if(!field_data) var field_data = "#data"; $("#data").datepicker({ dateFormat: "dd/mm/yy", showOn: "both", buttonImage: "img/calendar.gif", buttonImageOnly: true, beforeShowDay: closeDay, onSelect: ajaxHorario('') }); function closeDay(date){ if (date.getDay()==0 || date.getDay()==6) return $.datepicker.noWeekends; else if (date.getDay()==5) /* sextas | pode-se desabilitar fds também e remover o if anterior) */ return [false]; else return [true]; } function ajaxHorario(url) { jQuery('#hora').attr('disabled', 'disabled'); jQuery('#status_hora').html('carregando...'); jQuery('#status_hora').removeAttr('class'); data = $("#data").val(); $.ajax({ url: 'ajax.horario.php?data='+data+url, type: 'GET', async: true, // precisa ser true context: jQuery('#retorno-horario'), success: function(data){ jQuery('#retorno-horario').html(data); jQuery('#status_hora').html(''); if($("#data").val()) { jQuery('#hora').removeAttr('disabled'); } } }); } ajaxHorario(''); $("#data").change(function() { ajaxHorario(''); // parametro vazio }); });