I have a drop down list and two textboxes on an ASP.Net MVC 3 view. The drop down lists numbers from 1 to 10. The two textboxes are both wired up to use the JQuery Datepicker.
When the user selects an option from the drop down, I would like JQuery code to clear the values in the two textboxes.
I have written the JQuery code below which does just this, however, when I go to submit the form details to the post method within my controller, the dates I have selected for the two textboxes are cleared.
This is my code to date:
$(document).ready(function () {
$('#equipment_warrantyLength').change(ResetDates); //fires when drop down changed
function ResetDates() {
alert("hello");
$("#equipment_purchaseDate").val(''); // clear textbox
$('#equipment_warrentyExpires').val(''); //clear textbox
}
});
The textboxes should only be cleared when the drop down is selected, but currently, they also clear when the user attempts to submit the form.
Any feedback would be much appreciated.