Problem: I would like to access the selected date value in a datepicker field using the onClose event.
Solution: You can access the selected day, month, and year in the second parameter of the callback function. Here's an example:
jQuery(document).ready(function(){ jQuery('input[name="wpcf-start-date[display-only]"]').datepicker("option", "onClose", function(dateText,inst){ console.log(inst.selectedDay + ' ' + inst.selectedMonth + ' ' + inst.selectedYear); }); });
Keep in mind that in JavaScript month is a zero-based index, so August will be 7.
Relevant Documentation:
http://api.jqueryui.com/datepicker/#option-onClose
https://www.w3schools.com/js/js_date_methods.asp
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.
This topic is split from https://toolset.com/forums/topic/datepicker-change-event/
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 1 reply, has 2 voices.
Last updated by 6 years, 2 months ago.
Assisted by: Christian Cox.