JQuery Datepicker – no default date

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.

Leave a Comment