jqury datepicker disabled days

jqury datepicker disabled days

Good morning from Santo Domingo
I love Jquery !!!!!!
Please help me with this , I'm using Jquery datepicker daterange and I need to disable some days dinamically controlled  from a textbox on my form.  The default value of the textbox is   [2, 4, 5]  and i want to pass this value to the var daysToDisable like this :
 
var daysToDisable = document.myform.mytextbox.value;
 
instead of :  var daysToDisable = [2, 4, 5];
 
But it's not working . Why it's not working , where is the prolem ?
  
This is the code:
  1. $(function () {
  2. var daysToDisable = [2, 4, 5];
  3. $("#from").datepicker({
  4. beforeShowDay: disableSpecificWeekDays,
  5. defaultDate: "+1w",
  6. changeMonth: true,
  7. numberOfMonths: 3,
  8. onClose: function (selectedDate) {
  9. $("#to").datepicker("option", "minDate", selectedDate);
  10. }
  11. });
  12. function disableSpecificWeekDays(date) {
  13. var day = date.getDay();
  14. for(i = 0; i < daysToDisable.length; i++) {
  15. if($.inArray(day, daysToDisable) != -1) {
  16. return [false];
  17. }
  18. }
  19. return [true];
  20. }
  21. $("#to").datepicker({
  22. defaultDate: "+1w",
  23. changeMonth: true,
  24. numberOfMonths: 3,
  25. onClose: function (selectedDate) {
  26. $("#from").datepicker("option", "maxDate", selectedDate);
  27. }
  28. });
  29. });