0

I'd like to change the Default altFormat, but I can't seem to get it to work.

$("#myFav").datepicker({ dateFormat: 'yy-mm-dd' });
$("#myFav").datepicker('option', 'dateFormat', 'yy-mm-dd');

I thought altFormat would work just the same?

3 Answers 3

1

Have you tried what the documentation says:

$('.selector').datepicker({ altFormat: 'yy-mm-dd' });

or

$('.selector').datepicker('option', 'altFormat', 'yy-mm-dd');

For both the dateFormat and the altFormat:

$('.selector').datepicker({ dateFormat: 'yy-mm-dd', altFormat: 'yy-mm-dd' });
Sign up to request clarification or add additional context in comments.

Comments

0

This changes the dateformat in my application:

$("#startdate").datepicker({dateFormat: 'dd-mm-yy'});

Comments

0

dateFormat set the date of the input that datepicker was called on, use altFormat and altField if you want to set the value of a seperate field (a hidden field that actually get sent to database, or is shared somehow by the application)

This code worked for me:

[IN HTML]

<label for="display_date">Display/Start Date</label><br />

<input type="text" class="dateStart" name="display_date" value="" /><br />

<label for="display_date_end">End Date</label><br />

<input type="text" class="dateEnd" name="display_date_end" value="" /><br />

[IN JAVASCRIPT INCLUDE]

// set the datePicker on the start and end fields

$('input.dateStart').datepicker({dateFormat:"yy-mm-dd", changeYear: true});

$('input.dateEnd').datepicker({

dateFormat:"yy-mm-dd",

changeYear: true,

beforeShow: function(){

var value = $(this).siblings('.dateStart').val();

$(this).datepicker('option', 'minDate', value);

}

});

bo huttinger

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.