WordPress.org

Ready to get started?Download WordPress

Forums

Multi-language Responsive Contact Form
[resolved] Remove default values (6 posts)

  1. amandapiasta
    Member
    Posted 7 months ago #

    I would like the default values in my form to be removed when that element is focused on, but not if something different has been written on blur.

    I have been using this code for other forms, but it doesn't work when I put it into the Responsive Contact Form script area:

    //remove form values when user clicks in the field.
      $('.rmv-dft-val').click(
    		function() {
    			if (this.value == this.defaultValue) {
    				this.value = '';
    			}
    		}
    	);//close on click
    
    	$('.rmv-dft-val').blur(
    		function() {
    			if (this.value == '') {
    				this.value = this.defaultValue;
    			}
    		}
    	);// close on blur

    The website is http://taragaucher.com/directory/contact/

    http://wordpress.org/plugins/responsive-contact-form/

  2. August Infotech
    Member
    Plugin Author

    Posted 7 months ago #

    Hello amandapiasta,

    please try removing functions onblur="replace[field name]()" from Plugins\responsive-contact-form\include\ai-contact-form-template.php page and include your script in same page,
    and please correct errors in input fields, spacing before and after attributes as I found it on your site.

    If you still find any trouble, please let us know.

    Regards,
    August Infotech

  3. amandapiasta
    Member
    Posted 7 months ago #

    Hi August,

    thanks for the reply. Where does the extra space come from? I have no idea why that is there. I am viewing it in developer tools for chrome and it shows me something like this:

    <div class="control-group message">
      :before
    <label class="control-label" for="ai_comment">...</label>
    <div class="controls">...</div>
      :after
    </div>

    I assume you are talking about the :before and :after spots ...but I don't know where those are being inserted.

  4. amandapiasta
    Member
    Posted 7 months ago #

    Well i figured out how to remove the previous stated :before and :after ... they were included from the contact.css

    It still does not seem to be working... seems to be another javascript error because if I do not include my code it works, but if I add it in, it doesn't work. :/

    I have added the following in ai-contact-form-template.php above the functions:

    $(document).ready(function() {
    	//remove form values when user clicks in the field.
    	  $('.rmv-dft-val').click(
    			function() {
    				if (this.value == this.defaultValue) {
    					this.value = '';
    				}
    			}
    		);//close on click
    
    		$('.rmv-dft-val').blur(
    			function() {
    				if (this.value == '') {
    					this.value = this.defaultValue;
    				}
    			}
    		);// close on blur
    	});
  5. August Infotech
    Member
    Plugin Author

    Posted 7 months ago #

    Hello amandapiasta,

    We have found below jquery error in your contact page.
    Error: TypeError: $ is not a function
    Source File: http://taragaucher.com/directory/contact/
    Line: 7254

    Solution is : put jQuery instead of $
    Kindly check and put below code in your template.

    jQuery(document).ready(function() {
    	//remove form values when user clicks in the field.
    	  jQuery('.rmv-dft-val').click(
    			function() {
    				if (this.value == this.defaultValue) {
    					this.value = '';
    				}
    			}
    		);//close on click
    
    		jQuery('.rmv-dft-val').blur(
    			function() {
    				if (this.value == '') {
    					this.value = this.defaultValue;
    				}
    			}
    		);// close on blur
    	});
  6. amandapiasta
    Member
    Posted 7 months ago #

    Sweet, it works!

    Thanks August!

Reply

You must log in to post.

About this Plugin

About this Topic