简体   繁体   中英

How can i disable the previous dates in html code?

I tried so many ways I found online and nothing works for me. Please help me figure out and thanks alot.

Here is my codes. Now I just use simple date/calendar because I couldn't find anything else. It works fine but I need the system to not to be able to select previous date.

<!-- Date -->
<div class="box-body">
    <div class="form-group">
        <label class="col-sm-2 control-label">Date:</label>
        <div class="col-sm-10">
            <input type="date" name="date"/>
        </div>
    </div>
</div><!-- /.box-body -->

use min attribute of the element

 <input id='myDate' type="date" name="date" min="2015-10-28"/>

  document.getElementById("myDate").min = new Date().getFullYear() + "-" + parseInt(new Date().getMonth() + 1 ) + "-" + new Date().getDate() 
 Date: <input type="date" id="myDate" name="bday" min="2015-10-28" > <p><strong>Note:</strong> input elements with type="date" are not supported in Internet Explorer or Firefox.</p> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM