The problem is that when I clear the dates (by deleting the textbox values), th
I was trying to accomplish this very thing, that is, empty the datepicker so that filters entered by the user could be removed. Googling a bit I found this sweet piece of code:
You can add the clear feature even on read only fields. Just add the following code to your datepicker:
}).keyup(function(e) {
if(e.keyCode == 8 || e.keyCode == 46) {
$.datepicker._clearDate(this);
}
});
People will be able to highlight (even Read Only fields) and then use backspace or delete key to remove the date using _clearDate
function.
Source
$('.date').datepicker('setDate', null);
Reset the max date attributes on your datepicker when you click clear.
From jquery website
Get or set the maxDate option, after init.
//getter
var maxDate = $( ".selector" ).datepicker( "option", "maxDate" );
//setter
$( ".selector" ).datepicker( "option", "maxDate", '+1m +1w' );
you just need to set the options again to null:
dates.datepicker( "option" , {
minDate: null,
maxDate: null} );
I've changed your jsfiddle: http://jsfiddle.net/tF5MH/9/
Did you try:
$('selector').datepicker('setDate', null);
That should work according to the API documentation
In Firefox it does job for me in form (programmatically), where datepicker control is disabled by default:
$("#txtDat2").prop('disabled', false); //temporary enable controls<br>
$("#txtDat2").val("YYYY-MM-DD"); //reset date to dd.mm.yyyyy
$("#txtDat2").prop('disabled', true); //back to default state