Nepethya Rana

Nepethya Rana

  • NA
  • 335
  • 151.2k

could not able to render current date in textbox - Jquery

Aug 11 2017 10:15 AM

I have input text box for date. I am using JQuery Date picker.
I want to set and render the current date in my text box when page loads as default.
I could not able to do it. This is my code. Its not working.
Please look at and help me out.
<label for="dateSelection">Date:</label>
<span style="background-color: antiquewhite; padding-top: 3.6px; padding-bottom: 3.6px;">
<input type="text" id="dtID" name="dateSelection" placeholder="mm/dd/yyyy" ng-model="txtDate" required />
<span class="glyphicon glyphicon-calendar" style="padding-right: 3.6px;"></span>
</span>

$(document).ready(function () {
$('#dtID').datepicker({
changeMonth: true,
changeYear: true,
showAnim: 'slideDown',
duration: 'fast',
dateFormat: 'mm/dd/yy',
onSelect: function (date) {
$scope.txtDate = date;
$scope.$apply();
}
}).setDate(new Date());
});

Answers (2)