I want to remove the default date in my JQuery Datepicker.
I try the following code:
$(this).datepicker({defaultDate: ''});
But it doesn't seem to work. Today's date is still selected as default.
Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );
To set current date in control to which jQuery UI datepicker bind, use setDate() method. Pass date object which needs to be set as an argument to setDate() method. If you want to set it to current date then you can pass 'today' as argument.
Display the current date and time in a date pickerClick the Data tab. In the Data type box, click Date and Time (dateTime). Click Format. In the Date and Time Format dialog box, in the Display the time like this list, click the option that you want, and then click OK.
I got round the problem using a hidden altField:
<div id="DatePicker"></div> <input type="hidden" value="" name="Date" id="Date" />
and the following script:
<script> $(function () { $('#DatePicker').datepicker({ altField: '#Date', // ID of the hidden field altFormat: 'dd/mm/yy' }); // Remove the style for the default selected day (today) $('.ui-datepicker-current-day').removeClass('ui-datepicker-current-day'); // Reset the current selected day $('#Date').val(''); }); </script>
Then, I used the hidden #Date field in my validation routines.
None of the answers at the time of this writing really worked for me, so here was my solution cobbled from a couple of answers (for an inline datepicker).
$('.calendar').datepicker("setDate", null); // this unsets the datepicker's internal selected date; it still shows a highlight on today's date that looks like a selected date though $('.calendar').find(".ui-datepicker-current-day").removeClass("ui-datepicker-current-day"); // this actually removes the highlight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With