By zubl on
Hello!
I want that, if you click into the textarea or the inputfield of a webform, the default value in this field disappears but by clicking on the outside of the webform (e.g. the content field or any image) the default value appears again. Thats my kind of problem right now.
In the following you see the solution of the module "custom search box":
onblur="if (this.value == '') {this.value = 'DEFAULT';}" onfocus="if (this.value == 'DEFAULT') {this.value = '';}"
Somebody an idea?
Thanks in advance!
zubl
Comments
I need this feature too
I alsto need this feature. I suppose we need to figure out how to manipulate the formsapi array for the webform in question?
captaindav
http://icfolson.com
Javascript approach worked
The following JQuery code seems to work great:
Note the above code will effect any Webform that has a field with a default value. I believe you could target a specific Webform by specifying its id in the first line.
I put the code in a .js file which I called from template.php:
I hope to make a patch to webform as there is an obvious need for this feature.
captaindav
http://icfolson.com
Another approach
The previous suggestion didn't work for me.
I found this different solution -> http://webdeveloper.beforeseven.com/jquery/default-text-field-value-disa...
After modifying small things, now this works for all forms and text areas across all drupal forms (including admin):
Also included this second code, making it work for text areas as well.
I implemented this the very same way the solution above was implemented.
works like a charm
so just put the above code into a js file
let's name it deftextvalue.js and put it in sites/all/themes/[themename]/js
then put a reference into your .info file like so
Flush cache and woppah! should work.
(if the above way of including the js could be optimized, let me know)
Small correction to second code (form-textarea)
If you include the first and second code snippets in the same file then the second code snippet (form-textarea) will not work (at least in my case it did not). I changed the "default_values" in the second code snippet to be "default_area_values". This avoids a conflict with the "default_values" in the first code snippet (form-text).
Fixed as follows:
what a life saver, thanks to
what a life saver, thanks to all who contributed to this post, extremely helpful, thank you!!!
Change
I implemented this to be css available, and work for inputs and textareas.
I know that its too late to do this changes but here is my code:
Is there any way to insert
Is there any way to insert some conditional code to disallow certain forms? IE I want this behavior on all but 2 of my forms, how could i disallow these two, but have this behavior by default on all other forms??
Please advise, thanks!
If you are trying to do this
If you are trying to do this on the search box, the custom search box module will do it for you.
How do I set this for only
How do I set this for only some forms and not all? The problem I am facing is that the script applies to all text fields even those on node/add pages. Anybody else facing this issue?
I too need this...essentially
I too need this...essentially if we could disallow all node edit forms that would be great
Yes, that would suffice. What
Yes, that would suffice. What I experience now is node edit pages get affected by this which makes editing pages very difficult.
I've been using Compact Forms
I've been using Compact Forms (http://drupal.org/project/compact_forms) module to achieve this.
Nice!
Nice little module that compact forms :)
Http://www.reloadmedia.com
clear default values in drupal 7 webform / auto hide default
i'm using this code on drupal 7, based on the above. i put it in a /js subfolder under mytheme folder
then i add this line to mytheme.info file, under ;scripts
scripts[] = js/clear-default.jsit works!
many thanks RoyE - your script works on my Drupal 7 install
Pefect
Work great Thanks...