Answers for "set min date for datepicker html"

11

html input date min

<label for="meeting">Next meeting (August 2021):</label>
<input type="date" 
       id="meeting" 
       name="meeting"
       min="2021-08-01" 
       max="2021-08-31"
       defaultValue="2021-08-01">
Posted by: Guest on March-20-2021
0

datepicker min max date

function getCurrentFinancialYear(strDocDate) {
        var startYear = "";
        var endYear = "";
        var docDate = new Date(strDocDate);
        if ((docDate.getMonth() + 1) <= 3) {
            startYear = docDate.getFullYear() - 1;
            endYear = docDate.getFullYear();
        } else {
            startYear = docDate.getFullYear();
            endYear = docDate.getFullYear() + 1;
        }
        console.log({startDate : startYear+"-03-01", endDate: endYear+"-03-31" });
        return {startDate : startYear+"-03-01", endDate:  endYear+"-03-31" };
    }

    $(document).ready(function () {

    $('.datepicker').datepicker({
        format: 'yyyy-mm-dd',
        maxViewMode: 0,
        todayBtn: "linked",
        clearBtn: true,
        autoclose: true,
        todayHighlight: true,
        startDate: getCurrentFinancialYear($('input.datepicker').val()).startDate,
        endDate: getCurrentFinancialYear($('input.datepicker').val()).endDate
    });
Posted by: Guest on February-02-2022

Browse Popular Code Answers by Language