views:

51

answers:

1

Hey

I have a datepicker, i want to only allow fridays to be selected, and i dont want any dates older than todays date to be selected.

I have two functions. Both work when they are used seperately, but not when they are both present, i have tried, but cant merge them together, how do i do it?

Thank you

//Get todays date var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

//No old dates
$(function () { 
  $('#datepicker').datepicker({ 
  minDate: (new Date(d))
 }); 
});
//Only Friday
$(function () { $("#datepicker").datepicker({beforeShowDay: function(d) {return ( 5==d.getDay()? [true,''] : [false,'']);} }); });

</script>
+1  A: 

I'd say this should work fine:

$(function () { 
                $('#datepicker').datepicker({ 
                minDate: (new Date(d)),
                beforeShowDay: function(d) {return ( 5==d.getDay()? [true,''] : [false,'']);} 
        }); 
});
Matias
Thanks mate ! worked great