Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Remove default text on click - Form & List Module 6.0.2 Remove default text on click - Form & List Module 6.0.2
Previous
 
Next
New Post
7/23/2012 4:31 PM
 

Hello,

Is there a way to automatically remove the default field text from text and html/text fields? I have 3 fields...

Name

Email

Message

 I just want the default text to disappear when a user clicks into the field.

I was able to achieve this for the DNN Search textbox by adding  onblur and on focus to the Textbox line and a small bit of JS.

<asp:TextBox ID="txtSearch" runat="server" CssClass="SearchTextBox" Columns="20" MaxLength="255" Text="Search" onblur ="DefaultText(this, event);" onfocus ="DefaultText(this, event);"  style =" color:#434343" EnableViewState="False"></asp:TextBox>

 <script type = "text/javascript" >
    function DefaultText(txt, evt) {
        if (txt.value.length == 0 && evt.type == "blur") {
            txt.value = "Search";
            //grey
            txt.style.color = "#BFC0BD";
        }
        if (txt.value == "Search" && evt.type == "focus") {
            txt.value = "";
            //Black
            txt.style.color = "black";
        }
    }
    </script>

If anyone knows how to do this for the form and list 6.0.2 module it would be awesome! I'm not great with xslt and I'm not sure where to start really.

Best Regards,

Mario

 
New Post
11/27/2012 6:51 PM
 

I'm going to answer my own question as I have witten a JS that took care of this issue maybe someone else will find it helpful.

1.<script>
2.   $('input#dnn_ctr472_Default_Form_Name').focus(function () { $(this).val(''); });
3.   $("input#dnn_ctr472_Default_Form_Name").blur(function () { if ($(this).val() == "") { $(this).val("Name"); } });
4.   $('input#dnn_ctr472_Default_Form_Email').focus(function () { $(this).val(''); });
5.   $("input#dnn_ctr472_Default_Form_Email").blur(function () { if ($(this).val() == "") { $(this).val("Email"); } });
6.   $('textarea#dnn_ctr472_Default_Form_Message').focus(function () { $(this).val(''); });
7.   $("textarea#dnn_ctr472_Default_Form_Message").blur(function () { if ($(this).val() == "") { $(this).val("Message"); } });
8.</script>

 You will have to replace the module id with what your page is showing when you inspect the element. You may also want to switch out the default text for whatever you used in the form settings. Hope this saves someone a headache. 

Mario

 

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Remove default text on click - Form & List Module 6.0.2 Remove default text on click - Form & List Module 6.0.2


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out