with asp.net, how can pass javascript date into input with type datetime.
input tag:
<input asp-for="EndingDate" id="enddate" />
and the attempt to send javascript date to the input value:
const d = new Date("2015-03-25");
$('#enddate').val(d.toJSON());
CodePudding user response:
Did you try below.
const d = new Date("2015-03-25");
$('#enddate').val(d);
This will assign date time to asp.net text filed. But no-masking and calendar. If the field have calendar then you need to call calendar initiate method after this.
$("#enddate").datepicker();
The form post should work as it is.
CodePudding user response:
Try this
let endDate = new Date().toISOString().substr(0, 10); //Get Date part
$('#enddate').attr('value',endDate);