Using bootstrap datetimepicker. Submitting the form via ajax and need to reset date based on ajax response. But currently facing an issue to reset the date selection from JQuery. Here is the code I used to reset:
$("#date_from").datetimepicker("setDate", null);
Using bootstrap datetimepicker. Submitting the form via ajax and need to reset date based on ajax response. But currently facing an issue to reset the date selection from JQuery. Here is the code I used to reset:
$("#date_from").datetimepicker("setDate", null);
Share
Improve this question
asked Mar 17, 2016 at 7:04
Web_DeveloperWeb_Developer
1,2513 gold badges20 silver badges34 bronze badges
1
- Which version you are using?? – Moumit Commented Mar 17, 2016 at 7:19
5 Answers
Reset to default 3Can you try this.
$('#date_from').val("");
$('#date_from').datetimepicker('update');
Refered from methods tab of datepicker
Try this code:
$('#date_from').data("DateTimePicker").clear();
reference here: https://eonasdan.github.io/bootstrap-datetimepicker/Functions/#clear
@Jayaraj.K's answer did not work for me.
This is what I used:
$('#date_from').data('DateTimePicker').date(null)
$('#date_from').datetimepicker('update');
$("#date_from").datepicker().datepicker("setDate", new Date());
Try this code:
$.datepicker._clearDate(this);