Show dropdown on entering text

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 28 Jun 2012 Link to this post

    I want to make the dropdown show only when user types anything in the input from client side?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Jun 2012 Link to this post

    Hi Tina,

    Try the following Javascript to achieve your scenario.

    JS:
    <script type="text/javascript">
          var x = 0;
          function OnClientDropDownOpening(sender, args)
        {
             if (sender.get_text().length == 0)
             {
                 if (x == 0)
                 {
                     args.set_cancel(true);
                 }
                 else
                 {
                     x = 0;
                 }
             }
        }
        function OnClientKeyPressing(sender, args)
        {
             var val = args._domEvent.keyCode;
             if (((val > 95) && (val < 106)) || ((val > 64) && (val < 91)))
             {
                 x = 1;
                 sender.showDropDown();
             }
        }

    Thanks,
    Princy.
Back to Top