Hi EOSlover,
Do you have a link to the page you are trying this on? Also, are you loading this via an external JavaScript file or are you writing this inline in the head?
I’m going to test, and will report back here with some findings.
Evan
Hi again EOSlover,
After some quick testing I can confirm that the following works as expected:
/**
* Clear values and replace them on focus/blue for Easy Forms for MailChimp by YIKES
* reference: https://ww.wp.xz.cn/support/topic/clear-input-field-on-focus?replies=2
*/
function clear_value_of_form_field() {
?>
<script type="text/javascript">
jQuery( document ).ready( function() {
jQuery('input[type="text"], input[type="email"]').each(function(){
var txtval = jQuery(this).val();
// replace with '' on focus
jQuery(this).focus(function(){
if( jQuery(this).val() == txtval ){
jQuery(this).val('')
}
});
// replace value if nothing was entered
jQuery(this).blur(function(){
if( jQuery(this).val() == "" ){
jQuery(this).val(txtval);
}
});
});
});
</script>
<?php
}
add_action( 'yikes-mailchimp-shortcode-enqueue-scripts-styles', 'clear_value_of_form_field' );
Feel free to copy and paste that code directly into your functions.php file for testing. Let me know if that works.
Evan
Plugin Contributor
Tracy Levesque
(@liljimmi)
🏳️🌈 YIKES, Inc. Co-Owner
Hello EOSlover,
Please let us know if this fixed your issue or if you need further help.
Thank you!
-Tracy
Plugin Contributor
Tracy Levesque
(@liljimmi)
🏳️🌈 YIKES, Inc. Co-Owner
Hello EOSlover,
We haven’t heard from you in awhile so I am going to close out this ticket. Please let us know if that code helped you, or if you need any further help.
Thank you!
-Tracy
Hi Tracy,
I went the other way and solved it on my own.