0

I am using Razor syntax and to bind date type input I used data_ng_model = 'date' as it works in html razor. By Default in input field it displays dd/mm/yyyy. I am changing value date from angularJS script but it doesn't affect the display. Then I used Jquery to change the value attribute of that input field, it changes the value as I observed using inspect element but the display is still dd/mm/yyyy. For example if using jquery I change the value to 10/09/2016, it always displays dd/mm/yyyy. My code is like:

date = "10/09/2016";
$scope.date = (date.getDate() < 10 ? '0' : '') + date.getDate() + "/" + ((date.getMonth() + 1) < 10 ? '0' : '') + (date.getMonth() + 1) + "/" + date.getFullYear();
$("#eventDate").attr("value",$scope.date);

I think it should change the display of input field using $scope.date as i am binding it like

@Html.TextBoxFor(model => model.Date, new {
    @class = "form-control", 
    @type = "date", @id="eventDate", 
    data_ng_model = "date", 
    ng_change = "checkMe()" 
})
jwpfox
  • 5,124
  • 11
  • 45
  • 42
  • Possible duplicate of [jquery dates does not populate model object on post action](http://stackoverflow.com/questions/39183169/jquery-dates-does-not-populate-model-object-on-post-action) – Tieson T. Sep 09 '16 at 23:53
  • It needs to add jquery datepicker library, but i am using angularJS, i want to directly bind it – tanveer ashraf Sep 10 '16 at 00:02

0 Answers0