Unbounce Answers/Next Steps/Tips & Tricks

How to make "hint" (default) text for form input fields

Carter Gilchrist
posted this on January 24, 2011 12:20 pm

A number of people over on our Get Satisfaction community have asked how to make some default text appear in form fields and disappear when the field is selected. We would love to get this feature built into Unbounce soon, but until that happens, here's a work around using a little bit of JavaScript:

Click the "Javascripts" button, select 'Head' in the Placement dropdown menu, and paste in the following:

And if you want to change the color of the hint text, cut and paste the following to the "Stylesheets" section:

In the snippet above you'll see a list of fields at the top ("name", "email", and "comments") with their associated hint text. You'll need to change these to match the fields in your page that you want to give hints to - you can see these field names in the form builder as shown in the following screenshot:


form_field_name.png

Click here to view a demo of the above script in action...

 

Comments

User photo
Keshab Dey

Why we can't access the default "value" attribute of a textbox element? This way its easier and we can set the "onfocus" and "onblur "properties

March 21, 2011 05:01 am
User photo
Saptarshi Nath

Doesn't work for me. I can still see the blank form, no hint in my e-mail box.  I am using the default paste from above without changing any of the script. Should I be doing something different?

November 19, 2011 01:17 am
User photo
CapitolCrypt L3C

Pretty sure this doesn't work for the "multi line text field" option.  Any suggestions for a tweak to make it work with these fields?

December 22, 2011 09:39 pm
User photo
Phil Nind

Needs to be added to the header section, which is chosen when you click scripts. Theres a drop down at the top select "header" paste code and match up the labels and it should work...

March 05, 2012 04:48 am
User photo
Carter Gilchrist
Unbounce

Hey guys, sorry for such a delay on improving this. The original article/script has been updated to accomodate textareas (or multi-line text fields as they are called in the Unbounce form editor). 

April 10, 2012 02:58 pm
User photo
Paul Cardwell

i would love for unbounce to incorporate an easier way to do this!

April 19, 2012 12:19 pm
User photo
Ozgul Berkan

It's a very simple feature but it's still missing. Very annoying!

May 31, 2012 05:23 am
User photo
Colin Johnston

any way to make the hint text in italics?

December 01, 2012 08:49 pm
User photo
Brendan Sera-Shriar

Awesome - worked like a charm ...

December 03, 2012 10:02 am
User photo
Ryan Engley
Unbounce

@Colin - you should be able to do that with some CSS.  Carter gives an example (above) for how you can change the font color and using that same code, you can add another line to make the text italic.  Try this out:

<style type="text/css">
  .lp-pom-form-field .hint {
    color:#999999 !important; /* Grey */
    font-style:italic; !important
  }
</style>
December 03, 2012 11:14 am
User photo
Develon srl

hey, when i put this script, some of my requiredfield disappear..i meant, they became not required but they still marked as required.

is it clear? i hope so..

April 03, 2013 02:21 am