简体   繁体   中英

Javascript date picker multiple select

I'm a newbie in using JavaScript so I really don't know how to create a datepicker input field that will allowed multiple select. I did some searching but can't find a solution related to my case. Can you please help me? Thank you so much =)

This is what I tried so far

<script type="text/javascript" language="javascript">
     function pageLoad(sender, args) {
         $(document).ready(function() {
             $("#<%=datepicker.ClientID %>").datepicker();
             $(".ui-datepicker-trigger").mouseover(function() {
                 $(this).css('cursor', 'pointer');
             });
         });
     }
     $(function() {
         $("#datepicker").datepicker();
     });
</script>

<input type = "text" id = "datepicker">

This is working in a single select only. What I want to do is to be able to select a multiple dates. Thanks!

You can use MultiDatePicker a jQuery plugin to solve your problem. Here is the demo code for using MultiDatePicker :

You just need to include the script and style needed for MultiDatePicker plugin :

  <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"/>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"/>
    <script src="http://multidatespickr.sourceforge.net/jquery-ui.multidatespicker.js"/>

   <input id="datePick" type="text"/>
   <script>
   $('#datePick').multiDatesPicker();
   </script>

Here is a live demo

If you find any bugs by using this plugin you can report them here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM