Is there a way to clear a field's 'default value' when the user clicks on it?

Thanks.

Comments

quicksketch’s picture

You can do this through JavaScript but it would involve custom coding. A module like Hint actually does exactly what you want but it doesn't yet include any Webform support.

sorensong’s picture

@quicksketch thanks for the guidance. With a little more searching (with your help) I was able to find a module that did exactly what I was looking for:

http://drupal.org/project/compact_forms

quicksketch’s picture

Status: Active » Fixed

Super, thanks for the followup.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

moshfeather’s picture

In D7, I was able to get this functionality by adding this jQuery to my custom webform-form.tpl.php file that I had moved into my theme folder. Maybe it'll help someone else.

<script type="text/javascript">
   (function ($) {
    $(document).ready(function() {

   var swap_val = [];

   $(".webform-client-form .form-text, .webform-client-form .form-textarea").each(function(i){
       swap_val[i] = $(this).val();
       $(this).focus(function(){
           if ($(this).val() == swap_val[i]) {
               $(this).val("");
           }
       }).blur(function(){
           if ($.trim($(this).val()) == "") {
               jQuery(this).val(swap_val[i]);
           }
       });
   });


   });
   })(jQuery);
</script>
damir’s picture

@ moshfeather

Thank You.

xbrianx’s picture

@ moshfeather wow, was looking everywhere to find this solution. Thanks! totally worked.

BrendanP’s picture

@moshfeather
Thanks, that worked well for me.

Guy Borghouts’s picture

Issue summary: View changes

@ moshfeather
Thanks! Works perfectly!

Ekki’s picture

@moshfeather
perfect, thanks!