PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Add default value for Name field(s)?

  1. mmtrav
    Member

    I've always wondered why you couldn't set the default values for the name fields in all Gravity Forms, the way you can do it for the e-mail address and all the other fields.

    The reason is that I like to design forms that have the labels inside the field boxes themselves and that gives me a bit more design room to play with.

    Is there a way to accomplish this on form load that I don't know? Or is there a way I'm not seeing on the backend?

    Posted 8 years ago on Monday December 20, 2010 | Permalink
  2. An option to set a default value for a name field doesn't make a lot of sense to me. I understand you want to use it instead of a label though. You could accomplish this with some jQuery on the page load.

    Something like this..

    <script type="text/javascript">
    jQuery(document).ready(function() {
    	jQuery("#input_1_2.3").attr("value", "enter your first name");
    	jQuery("#input_1_2.6").attr("value", "enter your last name");
    });
    </script>

    screenshot: http://grab.by/7Z2L

    We may have an option for inline labels in a future release - we're still considering it.

    Posted 8 years ago on Monday December 20, 2010 | Permalink
  3. mmtrav
    Member

    Thanks Kevin. This jQuery solution works perfectly for my needs.

    Posted 8 years ago on Monday December 20, 2010 | Permalink
  4. mmtrav
    Member

    Well.. almost perfectly. I also want the fields to clear when on focus, so I used the script from this link:

    http://www.gravityhelp.com/clearing-default-form-field-values-with-jquery/

    Unfortunately it doesn't work with the jquery above used to populate the name field, as that is not specified as a 'this.defaultvalue' in the first place and is being added by jquery.

    I get the sense this should be easy but because I don't know javascript I'm struggling. Could I get a bit of code to make it work?

    Posted 8 years ago on Tuesday December 21, 2010 | Permalink
  5. Exact same predicament here :). I don't know enough about jQuery to figure out priority. Any ideas or suggestions?

    Posted 8 years ago on Tuesday April 12, 2011 | Permalink
  6. Any follow-up? I'm hoping to do this as well.

    Posted 8 years ago on Thursday May 5, 2011 | Permalink
  7. redhillcrea.tv
    Member

    +1 for this.

    Is there any suggestions to get this to work?

    Thanks

    Posted 7 years ago on Friday April 27, 2012 | Permalink
  8. redhillcrea.tv
    Member

    Hi All,

    I puzzled over this for a bit then realised that the #input was incorrect.
    I changed :
    #input_1_2.3 to #input_1_2_3 and #input_1_2.6 to #input_1_2_6 . ( replace the period . symbol with an underscore _ ) and this worked fine.

    Well at least for me it did.

    Hope this helps

    Posted 7 years ago on Friday April 27, 2012 | Permalink
  9. redhillcrea.tv
    Member

    Scratch that.

    This works for some reason on my local WAMP, but NOT on my godaddy hosting?

    Weird much?

    Here is a post of my ongoing saga to include this and similar jQuery into my GF:
    http://www.gravityhelp.com/forums/topic/where-should-i-place-custom-jquery

    Posted 7 years ago on Friday April 27, 2012 | Permalink