Home » Jquery » Datepicker altField

Datepicker altField

Date  Format/datepicker altField

What is datepicker altfield? How to change the date format in datepicker when we want to send the date in a different format to server? Or how to set datepicker altField?

Datepicker altField

Datepicker

First we have to add a hidden field for getting the different format of date next to the datepicker input field.

<input type="hidden" id="alt_field" />

Then we have to add the jquery like the following.

$('#id').datepicker({altField:'#alt-date', // assigning alternative fieldminDate:new Date(),altFormat: 'dd-M-yy', //Setting format for the alternative (hidden) fielddateFormat:'dd-mm-yy' //Setting default format for displaying to the user

}).
datepicker('setDate', new Date()); //setting the date

Here the hidden field will have the date format ‘dd-M-yy’ ¬†that is 12-Jul-2013

But, the value of the field which the user can see is ‘dd-mm-yy ‘, that is 12-07-2013.

 

More details about Datepicker

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*