javascript - jQuery UI Datepicker be made to disable weekends and holidays? - Stack Overflow

I have seen an exact question being answered, but the problem is, I have absolutely no idea where to pa

I have seen an exact question being answered, but the problem is, I have absolutely no idea where to paste the codes shown here for mine to work. I am really a noob when it es to programming.

Would appreciate if someone would be so kind to enlighten me as I desperately need to get my calendar working. :(

Thank you so much.

I have seen an exact question being answered, but the problem is, I have absolutely no idea where to paste the codes shown here for mine to work. I am really a noob when it es to programming.

Would appreciate if someone would be so kind to enlighten me as I desperately need to get my calendar working. :(

Thank you so much.

Share Improve this question edited May 23, 2017 at 12:16 CommunityBot 11 silver badge asked Dec 30, 2010 at 9:06 Spiral1ngSpiral1ng 3231 gold badge8 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2
var holidays= ["2014-7-30","2015-07-29","2013-03-16"]

$('input').datepicker({
beforeShowDay:  function(date){
    var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
     var noWeekend = $.datepicker.noWeekends(date);
         if (noWeekend[0]) {
        return  [$.inArray(string, holidays) == -1];
        }
        else
        return noWeekend;
    }
});

I'll try to answer:

How to start you'll find - here

You will need theese: (link them in top of your page.)

  1. jQuery Library: Datepicker requires including jQuery.
  2. JavaScript: ui.core.js and ui.datepicker.js
  3. CSS Theme: Create your theme with ThemeRoller

You can find great demo about basis - here

<script>
 $(function() {
   /*function that makes appear datepicker + you add option to disable Weekends*/
   $(".selector").datepicker({ beforeShowDay: $.datepicker.noWeekends }) 
 });
</script>

<div id="demo">
  <p>Date: <input class="selector" type="text"></p> //input field that calls the function
</div>

2 things to do:

  1. link jquery.js + ui.core.js and ui.datepicker.js + your css theme to your page
  2. paste this code into your webpage.

I can suggest you to do as i did - run threw a lot of tutorials, and most important thing to do - experiment!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745383612a4625343.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信