• Resolved EOSlover

    (@eoslover)


    Hi,

    I’m having a problem with this plugin. I cant clear the input field with jQuery.

    $('input:text, input[type="text"], input[type="email"]').each(function(){
    		var txtval = $(this).val();
    		$(this).focus(function(){
    			if($(this).val() == txtval){
    				$(this).val('')
    			}
    		});
    		$(this).blur(function(){
    			if($(this).val() == ""){
    				$(this).val(txtval);
    			}
    		});
    	});

    I’m using Swipebox.

    https://ww.wp.xz.cn/plugins/yikes-inc-easy-mailchimp-extender/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Evan Herman

    (@eherman24)

    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

    Plugin Author Evan Herman

    (@eherman24)

    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

    Thread Starter EOSlover

    (@eoslover)

    Hi Tracy,

    I went the other way and solved it on my own.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Clear input field on focus’ is closed to new replies.