Navigation überspringen

[Gelöst] Datepicker

This support ticket is created vor 3 Jahren, 11 Monaten. 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: Africa/Casablanca (GMT+01:00)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Puntorosso vor 3 Jahren, 11 Monaten.

Assistiert von: Jamal.

Author
Artikel
#2056031

Hi, I have created a date/time custom field with Toolset.
How can I restrict the datepick input to a date/time before "now"?
Thanks.

#2056127

Hello and thank you for contacting the Toolset support.

The datepicker is from jQuery UI. You can use the maxDate option on it versteckter Link

Listen for the form's ready event, and apply the maxDate. Something like this should work:

jQuery(document).on('cred_form_ready', function() {
  jQuery( ".js-wpt-date" ).datepicker({ 
      maxDate: 0
    }); 
 });

The forum has several threads about the datepicker customization. Maybe they may help:
versteckter Link

I assumed that you are talking about a Toolset form. Let me know if it is not the case.

#2056189

Hi Jamal,
Thanks for the tip.
I was talking about a Toolset custom field on backend, assigned to WooCommerce orders.

#2056659

Use the browser developer tools to get the name, id, or class of the field in the backend. Then use a plugin or custom code to add your Javascript code to the backend. https://wordpress.org/plugins/code-snippets/

Read more about jQuery selector here versteckter Link

Rely on the "ready" event:

jQuery(document).on('ready', function() {
  var selector = ".js-wpt-date";   // get the selector using the browser developer tools
  jQuery( selector ).datepicker({ 
      maxDate: 0
    }); 
 });

I hope this helps. Let me know if you have any questions.

#2056893

Hi Jamal,
I would need some help here, as I cannot get it work.

Would you be so kind to check this link and tell me which selector id I should use for the datepicker?
versteckter Link

Thanks.

#2057761

Of course. Would you allow me temporary access to your website to check it closely? I tried to figure it out from my side, but I'll need to access the backend to better handle it. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2065433

My issue is resolved now. Thank you!