I have a HTML5 design where I want to be able to use a button to display a date, but I want to use the HTML5 input type="date" to select the date.
Here is my code:
<button type="button" id="btnDate" class="btn btn-primary">
<span class="glyphicon glyphicon-calendar"></span> <span class="date">27 Jul 2015</span>
</button>
<input type="date" class="hidden" id="tbDate" />
<script type="text/javascript">
$(document).ready(function() {
$("#btnDate").click(function () {
$("#tbDate").focus();
});
});
</script>
I've tried focus() and click() - neither work...any ideas?
The <input type="date"> defines a date picker. The resulting value includes the year, month, and day.
To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.
<input type="date"> <input> elements of type="date" create input fields that let the user enter a date, either with a textbox that validates the input or a special date picker interface. The resulting value includes the year, month, and day, but not the time.
The max attribute specifies the maximum value (date) for a date field.
Please browse with your phone.
<label for="dateInput">click button</label>
<input type="date" id="dateInput" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With