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

Forums / Bugs & Issues / Feature Request on the Search Control

Feature Request on the Search Control

5 posts, 2 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    24 Mar 2011
    Link to this post
    Can you tweak the script of the search box so if the "InnerSearchBoxText" is showing it appends a class to denote that?...I would like to style the "empty text" state differently from when the user is actually searching for something.  So for example when the InnerSearchBoxText is there I want the text to be italic and faint, however when the user types something I want it to be dark and normal.
  2. Jordan
    Jordan avatar
    172 posts
    Registered:
    20 Oct 2015
    24 Mar 2011
    Link to this post
    Hi Steve,


    Here is a simple jQuery code that probably will cover your case. A CSS class "no entry" is appended when the default string is inside or the box is empty. When the user enter its text the class is removed.

    $(document).ready(function() {
        var $message = 'Type your keyword here';
        $('.sfsearchTxt').val($message);
        $('.sfsearchTxt').addClass('noentry');
        $('.sfsearchTxt').focus(function() {
            if($('.sfsearchTxt').val() == $message) {
                $('.sfsearchTxt').val('');
                $('.sfsearchTxt').removeClass('noentry');
            } else {
                $('.sfsearchTxt').removeClass('noentry');
            }
        });
        $('.sfsearchTxt').blur(function() {
            if($('.sfsearchTxt').val() == '') {
                $('.sfsearchTxt').val($message);
                $('.sfsearchTxt').addClass('noentry');
            }
        });
    })
         
        


    All the best,
    Jordan
    the Telerik team
    Answered
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    24 Mar 2011
    Link to this post
    Thanks, but yeah I know it can be done easily in jQuery :)

    I was just requesting that it be added to your current script...otherwise I'll need to implement it on every new site, and 99% of the time the empty text should look different from the search text otherwise the user will think they're searching for "Search..." (or whatever the default text is)
  4. Jordan
    Jordan avatar
    172 posts
    Registered:
    20 Oct 2015
    24 Mar 2011
    Link to this post
    Hi Steve,

    Sorry for the misunderstanding. Your request has been logged.


    Best wishes,
    Jordan
    the Telerik team
    Answered
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    24 Mar 2011
    Link to this post
    Awesome, thx for the snippit
5 posts, 2 answered