'How to disable pevious date in html form using min attribute of date datatype
I want to set min attribute to today's date and disable previous date in datepicker in html view page C#
<input type="date" min="new Date().today()"/>
Solution 1:[1]
There isn't min attribute that can disable the previous date without writing any js script.
You can try to use JQuery library datepicker API which supports disabling the previous date by minDate
$(function() {
$("#datepicker1").datepicker({
changeYear: true,
changeMonth: true,
minDate:0
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
Datepicker:<input id="datepicker1" type="text" required value="">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | D-Shih |
