0

I am using Two types of datepicker in my page in one field I am using jQuery Multidatepicker and on another input field I am using datepicker. Both are working fine but the problem is datepicker is not hiding after selecting a date.

HTML

<div>
<label>Start Date:</label> <br />
<s:textfield type="text" readonly="true" id="startDate" name="startDate"
class="form-control" autocomplete="off"/>
</div>

JAVASCRIPT In below code I used autoclose: true, but not working.

$("#startDate").datepicker({
    prevText : "click for previous months",
    nextText : "click for next months",
    showOtherMonths : true,
    dateFormat : 'dd/mm/yy',
    selectOtherMonths : false,
    maxDate : new Date(),
    autoclose: true
});

In below code I used autoHide: true, still not working

$("#startDate").datepicker({
    prevText : "click for previous months",
    nextText : "click for next months",
    showOtherMonths : true,
    dateFormat : 'dd/mm/yy',
    selectOtherMonths : false,
    maxDate : new Date(),
    autoHide: true
});

I wants to close calendar after selecting date automatically. Please tell me what is the problem.

The Khaleesi
  • 13
  • 1
  • 6
  • Possible duplicate of [jQuery Datepicker close datepicker after selected date](https://stackoverflow.com/questions/24040165/jquery-datepicker-close-datepicker-after-selected-date) – Syed mohamed aladeen May 10 '19 at 07:29
  • @Sayed Mohamed Aladeen I tried but nothing worked for me. – The Khaleesi May 10 '19 at 07:49
  • @TheKhaleesi do you have any demo or jsFiddle to reproduce this issue? Since this seems the application level issue only, so once we debug this then we can find the solution. – Soundar May 10 '19 at 08:29

2 Answers2

0

Check this code:

$(document).ready(function () {


    $('#startDate').datepicker({
        prevText : "click for previous months",
        nextText : "click for next months",
        showOtherMonths : true,
        dateFormat : 'dd/mm/yy',
        selectOtherMonths : false,
        maxDate : new Date()
    }).on('change', function(){
        $('.datepicker').hide();
    });


});
Pouya Jabbarisani
  • 1,084
  • 3
  • 16
  • 29
0

The datepicker should be closed automatically after user picking a date. I think maybe the bug is caused by some where else in your code, or you can simply try this first

$("#startDate").datepicker({});

benben994
  • 40
  • 9
  • this is true that datepicker closed automatically after selecting date. The simple code is working fine but the above code I provided is not working as expected. – The Khaleesi May 12 '19 at 04:29