Monday, March 14, 2022

[FIXED] Jquery Datepicker not rhiding past dates

Issue

Am using Jquery Datepicker for my project . If i want to change date format my code will be

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

Its not working . But if am using this format its working

$("#datepicker1").datepicker("setDate", '+1d');

Please provide me a solution . Thanks in Advance


Solution

To disable all previous dates, give start date as today date

startDate: new Date()

$(function() {
    $( "#datepicker" ).datepicker({ 
      format: 'dd/mm/yyyy',
      startDate: new Date(),
    });
 });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.css" rel="stylesheet"/>


<div> Select Date <input type="text" id="datepicker" /></div>



Answered By - Vipul L.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.