+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / Initial text in Newsletter Subscription

Initial text in Newsletter Subscription

2 posts, 0 answered
  1. Patrick Julicher
    Patrick Julicher avatar
    31 posts
    Registered:
    28 Feb 2010
    16 Mar 2010
    Link to this post
    Hi,

    I an usng the Firstname, Lastname, Email newsletter subscription type. What I'd like to do, is put initial text in the fields. This should disappear when a users clicks in a field (onfocus) and reappear when nothing is entered and something else is clicked (onblur).
    I tried a huge number of option from Google, but none seem to work.

    Kind regards,  Patrick
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Mar 2010
    Link to this post
    Hello Patrick Julicher,

    You can use js to extend the form . Below is a sample code

                         
    <script type="text/javascript">
            function hideLabel(obj,flag)
            {
                var lbl = obj.parentNode.getElementsByTagName('label')[0];
                if(flag) {
                    lbl.style.textIndent = "-99999px";
                } else {
                    if(obj.value === '')
                        lbl.style.textIndent = "0px";
                    else
                        lbl.style.textIndent = "-99999px";
                }
     
            }
            function focusSearchField(obj) {
                var id, field;
                id = obj.getAttribute('for');
                if (id && (field = document.getElementById(id))) {
                  field.focus();
                }
     
            }
    </script>
     
     
         <script type="text/javascript">
             $(document).ready(function() {
                 hideLabel(document.getElementById('txtSearchBox'), false);
             });
        </script>  
     
     
    <input name="txtSearchBox" type="text" id="txtSearchBox" class="tSearchBox" onfocus="hideLabel(this,true); " onblur="hideLabel(this,false); " />

    You could also use jQuery library - Jquery TextBox Help Plugin. You may also find this post useful - How to get a watermark inside the search text box

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered