jQuery datepicker to prevent past date

jQuery datepicker to prevent past date

Asked on December 24, 2018 in jQuery.
Add Comment


  • 3 Answer(s)

    The one thing we should do is, neglet the quotes from 0.

    $("#datepicker").datepicker({ minDate: 0 });
    
    
    Answered on December 24, 2018.
    Add Comment

    We have to specify a minimum date – set the minimum date value to 0 means that the minimum date is 0 days from today , that means today. We could send the string called ‘0d’ .

    $(function () {
        $('#date').datepicker({ minDate: 0 });
    });
    
    Answered on December 24, 2018.
    Add Comment

    Try this codes, It should works.

    // set minDate to 0 for today's date
    $('#datepicker').datepicker({ minDate: 0 });
    
    body {
        font-size: 12px; /* just so that it doesn't default to 16px (which is kinda huge) */
    }
    
    <!-- load jQuery and jQuery UI -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
     
    <!-- load jQuery UI CSS theme -->
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
     
    <!-- the datepicker input -->
    <input type='text' id='datepicker' placeholder='Select date' />
    

    Here, we remove the all neighbouring zeros , and it works fine.

     

    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.