Feature Request on the Search Control

Posted by Community Admin on 04-Aug-2018 04:30

Feature Request on the Search Control

All Replies

Posted by Community Admin on 24-Mar-2011 00:00

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.

Posted by Community Admin on 24-Mar-2011 00:00

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

Posted by Community Admin on 24-Mar-2011 00:00

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)

Posted by Community Admin on 24-Mar-2011 00:00

Hi Steve,

Sorry for the misunderstanding. Your request has been logged.


Best wishes,
Jordan
the Telerik team

Posted by Community Admin on 24-Mar-2011 00:00

Awesome, thx for the snippit

This thread is closed