I’m working on this and am hoping you can help!
I have a form which includes an email address.
When a user inserts an email address and then LEAVES that field, I’d like this to trigger an event: opening a popup window using the contents of the field as a parameter.
How can I hook into a field losing focus to trigger something?
Many thanks for your help!
Hi @marathra
You should be able to do it by using the jQuery focusout() method and acf/input/admin_footer hook to add the script. It should be something like this:
function my_acf_script_focusout() {
?>
<script type="text/javascript">
(function($){
$(document).ready(function(){
$(".acf-field-1234567890abc input").focusout(function(){
alert( $(this).val() );
})
});
})(jQuery);
</script>
<?php
}
add_action('acf/input/admin_footer', 'my_acf_script_focusout');
Where ‘acf-field-1234567890abc’ is based on the field key of your email custom field.
I hope this helps 🙂
Thanks, with a tiny bit of tweaking it worked fine!