mercredi 28 janvier 2015

jquery .val(object) not assigning the correct value MVC 5


I am working on a website (new to web development) and I am having an issue with the following code(setting the end date to tomorrow if it is blank):



var date = new Date($('#txtStartDate').val());

var tomorrow = date.getDate() + 1;

$('#txtEndDate').val(tomorrow);


Later in the same function



var myObj = {StartDate: $('#txtStartDate').val(), EndDate: $('#txtEndDate').val() };


I am using MVC 5 and when the object hits the controller the start date is set but the end date is still null (also using visual studio 2013 update 1 so debugging is broken since the js is in the cshtml file).


From searching, the code should work unless I have a mistake I am not seeing.





Aucun commentaire:

Enregistrer un commentaire