Navigation überspringen

[Gelöst] make datepicker required

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
The user would like to make a date-picker required inside a form.

Solution:
The date picker field stores the date inside a hidden input field. You can target it using Javascript as follow:

jQuery(function($){
    $('div[data-item_name="date-wpcf-day-of-birth"] input').prop('required', true)
})
This support ticket is created vor 4 Jahren. 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 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Puntorosso vor 3 Jahren, 12 Monaten.

Assistiert von: Jamal.

Author
Artikel
#2039135

How do I apply your Javascript solution to make the date field (day-of-birth) required?
versteckter Link

#2039159
#2039753

It turns out to be as simple as setting both inputs as required, the visible one is display_only, and it displays the value of the hidden one. We can target them with div[data-item_name="date-wpcf-day-of-birth"] input.


jQuery(function($){
    $('div[data-item_name="date-wpcf-day-of-birth"] input').prop('required', true)
})

Can you test it for a new order? the existing one has already the date value.

#2039907

Perfect! Thanks a lot Jamal.
Best