Updated jQuery Form Field Default Value Plugin

by Jason on May 27, 2011

Hi everyone,

I finally got around to updating my jQuery plugin.

I’ve cleaned up the code a bit and also ensured full compatibility with jQuery 1.6.

A few new features:

Option for property-based default value
Now, if you choose, you can add a label=”my default value” as a property to your input field and the plugin will utilize this value for the default. You can still utilize the old method as well.

Option to allow form submission to send default values
By default, if default values are detected when a form is submitted, the values are emptied so an empty value is sent through. Now, you have the option of allowing the default value to be submitted.

Simply use the following code:

jQuery.fn.DefaultValue.settings.clear_defaults_on_submit=false;

You can now find the latest version of the jQuery plugin on Github!

2 comments

Hi, nice plug-in!
I’ve tried to use it together with the jQuery Validation Plug-in.
In my case, instead of having a label next to the input fields, I use the default value to show the user what to type. When the form is submitted, the validation errors are correctly shown, but the default values are cleared. So in my case the user won’t have any idea what to write in the fields they’ve missed.. :-) Is it possible to make a tweak to your plug-in which could fill in the default values after submit, but only to the fields not filled with correct values?

by Jacob Jensen on June 16, 2011 at 5:24 am. #

hi, thanks for that great plugin. For any reason I have a strange problem with it on my webpage.

I open the page and your script is working perfect. Then I push F5 to reload the webpage – and from that point the script just stops working.. I can click into the fields and the text is just not disapearing.

I have this problem in IE9 and FF 6.0.2 … do you may have any idea what’s wrong?

Thanks

by Rolf on September 23, 2011 at 2:49 pm. #

Leave your comment

Required.

Required. Not published.

If you have one.