Search code examples
javascriptjquerydatepickerjquery-ui-datepicker

I am new to date picker. My requirement is to provide day picker from 1 to 31.


i searched about jquery datepicker but it provides date with months. All i want is multiple day picker from 1 to 31. example if user selects 1,5,14 i should get date = 1,5,14 in javascript variable.

Any simple example will be of great help thanks.


Solution

  • $('#mdp-demo').multiDatesPicker({
        dateFormat: "d-m-y",
    });
    
    $("#getDates").click(function(e){
        var days;
        var selectedDates = $('#mdp-demo').multiDatesPicker("getDates");
        for(i in selectedDates){
            if(days)
        	   days += ","+selectedDates[i].split("-",1);
            else
               days = selectedDates[i].split("-",1);
        }
        alert(days);
    })
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link href="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.css" rel="stylesheet"/>
    <link href="https://code.jquery.com/ui/1.12.1/themes/pepper-grinder/jquery-ui.css" rel="stylesheet"/>
    
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    <script src="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js"></script>
    
    <div id="mdp-demo"></div>
    <button id="getDates">
      Get Dates
    </button>

    Try MultiDatesPicker, may be it can help you.

    MultiDatesPicker