Skip Navigation

[Resolved] Datepicker starting from the current date in the edit form

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Wicus Spies 4 years ago.

Assisted by: Waqar.

Author
Posts
#1770693

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?

#1771737

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

#1831849
Screenshot 2020-11-02 at 12.56.15.png
Screenshot 2020-11-02 at 12.56.32.png

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!