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.

Highlight or delete default 'value' in field on click...

  1. Hi, I'd like to use a default value in my 'Single Line Text' fields, and then when someone clicks in the field have it either select the value for overwriting, or ideally remove it.

    The designing I'm working to doesn't have labels you see.. client thinks they are 'messy' :)

    I've had a pretty good search around and a read of the docs, but haven't seen a method. I could hack it probably with some JS/JQ but would rather use a built-in method or a tried and tested method if there is one.

    Cheers!
    Ben

    Posted 13 years ago on Thursday February 17, 2011 | Permalink
  2. This isn't a feature that is built in. The only way to currently do it is with some custom jQuery.

    See this post:

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

    It's a feature we do plan on adding in a future release.

    Posted 13 years ago on Thursday February 17, 2011 | Permalink
  3. Ok thanks, I didn't get on too well with the script in that link, and settled for this very simple select script until I have time to get a better one working:

    jQuery(document).ready(function($) {
    $("input.medium, textarea.medium").click(function () {
    this.select();
    });
    });

    The option to specify that a default value should validate as 'false' will be a much needed and appreciated feature I think. Many forms have the 'prompt' in the fields these days, for simplicity. Not sure what the standards and semantics guys would say, but from a UI point of view its much more straightforward than labels.

    Posted 13 years ago on Saturday February 19, 2011 | Permalink
  4. Hey Ben or Carl, where would I add that JQuery code exactly. I am looking to do this also to save space....

    Posted 11 years ago on Saturday September 8, 2012 | Permalink
  5. David Peralty

    Javascript code should go into the header.php file of your selected theme. Have a look at this article:

    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Posted 11 years ago on Saturday September 8, 2012 | Permalink