I am having a problem with the date field on an EDIT Post form. When I click on the date to edit it, it defaults to today's date in the date picker that pops up. I need it to show the date that is stored so the user can make a change to it easy. Make sense?
Hi,
Thank you for waiting.
During testing on my website, I was able to make the saved date in the edit form, get pre-selected in the date-picker pop-up, using this script:
jQuery(window).bind("load", function() {
var selDateValue = jQuery('input[name="wpcf-book-date[display-only]"]').val();
jQuery('input[name="wpcf-book-date[display-only]"]').datepicker( 'option', 'dateFormat', 'MM d, yy' );
jQuery('input[name="wpcf-book-date[display-only]"]').datepicker( 'setDate', selDateValue );
});
Note: Please replace all "book-date" instances, with the actual slug of your date field in the form.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hello Waqar!
Sorry for not responding sooner. I was pulled off to another project. The above code works by populating the date box with the date stored in the database but when I select a new date, it always goes to 1992-08-20 no matter what date I select from the date picker.
I use the following in the JS Editor:
jQuery(window).bind("load", function() {
var selDateValue = jQuery('input[name="wpcf-appointment-date[display-only]"]').val();
jQuery('input[name="wpcf-appointment-date[display-only]"]').datepicker( 'option', 'dateFormat', 'yy-mm-dd' );
jQuery('input[name="wpcf-appointment-date[display-only]"]').datepicker( 'setDate', selDateValue );
});
Can you please check this out for me? I would really appreciate it!
Thanks, man!