Home › Forums › Backend Issues (wp-admin) › How to trigger on close datepicker() event? › Reply To: How to trigger on close datepicker() event?
Hey John, once again you’ve saved the day. 🙂
This is what I ended up using. The setTimeout(). And added a check. I was not able to get the onSelect() to work 🙂
With the code below I was even able to split the validation into two parts! One while editing and one post editing. Nice.
$input.datepicker().on('input change select', function (e) {
$this = this;
// validate "live", directly on change
// for example, if date end indeed is later than date start
rtt_validate_datepicker_onChange($this, $input);
// validate after exiting the field
// for example, after populating start date AND exiting field, check if end date is empty, if so, than populate it with you desired value
// Debounce
setTimeout(function(){
// check if your input is still focused. If so, it went back in editing.
if ( ! $input.is(":focus") ) {
// alright, after debounce it is blurred, not focused.
// That means we actually left the field. Now it's time for your validation.
rtt_validate_datepicker_onBlur($this, $input);
}
}, 300);
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.