0

My Frondend Code

<div class="col-md-4">DisablePast Date</div>
<div class="col-md-8">
    <input class="form-control datepicker" type='date' id="date">
</div>

Script

$(function () {
$("#date").datepicker({ minDate: 0 });

});

Ss_Gupta
  • 73
  • 7

1 Answers1

2

Try this.

var dateToday = new Date();
$(function () {
    $("#date").datepicker({ minDate: dateToday })
});

<div class="col-md-8">
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
    <input class="form-control datepicker" type='date' name="date" id="date">
    </form>
</div>

php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['date'])) {
        //do processing
    }
}
Web Dev Guy
  • 1,693
  • 3
  • 18
  • 42
  • Okay, good, can you tell me how can we validate from server side. It's user side. thanks in advance – Ss_Gupta Feb 06 '17 at 08:23
  • Cool :) what server side programming language you using? – Web Dev Guy Feb 06 '17 at 08:30
  • I am using Php, can we validate in JS. when user select previous date after that submit button we alert them select "select date after today" . :) – Ss_Gupta Feb 06 '17 at 08:36
  • check http://stackoverflow.com/questions/27714469/check-if-date-is-in-the-past-without-submitting-form I got another answer too... and happy from your side.. – Ss_Gupta Feb 06 '17 at 09:59
  • check http://stackoverflow.com/questions/42062690/how-to-disable-select-previous-date-in-datepicker-js/42062836?noredirect=1#comment71298931_42062836 any about this question @Web Dev Guy – Ss_Gupta Feb 06 '17 at 12:31