3

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 -->
2
  • Can you please post your whole code for better understanding. @Sam Commented Oct 29, 2015 at 6:48
  • Hi. This is actually the whole codes for my date attribute. I didnt use any jquery or javascript. Commented Oct 29, 2015 at 8:40

1 Answer 1

4

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>

Sign up to request clarification or add additional context in comments.

2 Comments

and how to get the date before (which is 28-10-2015 for today) by default? I mean I dont want to hard code the date.
and i forgot, Thank you for the answer :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.