Input fields default values Script

More tags

Input fields default values
With this jQuery scriptlet you can easily assign default values to input fields. When focus is in the field, the value blurs, and when focusing elsewhere the default value shows again.
Author: Jason Price: Free Type: Javascript, jQuery

EXAMPLE

STEP 1

Insert the following script anywhere in the <BODY> section of the page. You must have jQuery loaded.

Click in textarea to select code then copy and paste Ctrl-CCtrl-V

STEP 2

Insert your form code where you want the form to appear in the page. Complete your form as is needed making sure you add any additional fields into the array basevalue in the jQuery code.

Click in textarea to select code then copy and paste Ctrl-CCtrl-V

BOOTSTRAP

If you use Twitter Bootstrap you can use also use placeholder="value" for each form field. This has the same effect, however, it does not work in every browser.