satish kilari
satish kilari

Reputation: 728

Why datepicker is unable to show when i click on datepickers next button?

$(document).on('focus',".expdate",function(){
    $('.expdate').datepicker({minDate:0});
    $(this).datepicker();
    $( ".expdate" ).datepicker('option','dateFormat','dd/mm/yy');
    $( ".expdate" ).datepicker("changeMonth", true );
});

I'm trying to disable all previous dates and I need to show all the next days maybe 2017 december also. Date format must be dd/mm/yy.

Upvotes: 0

Views: 70

Answers (2)

VincenzoC
VincenzoC

Reputation: 31482

You can use jQuery-ui datepicker options to create the component you need:

$(document).ready(function() {
    $('.expdate').datepicker({
        minDate: 0,
        maxDate: new Date(2017, 11, 31),
        dateFormat: 'dd/mm/yy',
        changeMonth: true
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet"/>

<input type="text" class="expdate">

You disable all previous date setting minDate to 0. maxDate lets you define the maximum selectable date (31/12/2017 in the example). Using dateFormat you can customize date format and you can enable month dropdown using changeMonth. You can find the complete reference in the official documentation.

Upvotes: 1

Vinothkumar Nataraj
Vinothkumar Nataraj

Reputation: 588

$('#appDatePick').datepicker({format: "dd/mm/yyyy",
    startDate: "today",
    endDate: '+2m',
    autoclose: true
});

(or)

$('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' });

use this one

Upvotes: 1

Related Questions