Clear value in javascript

2 posts, 0 answers
  1. Dan
    Dan avatar
    13 posts
    Member since:
    Nov 2009

    Posted 01 Mar 2013 Link to this post

    Hello,

    I have an AutoCompleteBox and am trying to clear the client-side value using a javascript function.

    I have given an example below with a comment at where I am unsure of what property to use. When the button is clicked any user inputted text should be cleared and the EmptyMessage appears.

    function ClearBox()
    {
        var box = $("#<%= ctrlBox.ClientID %>");
        //what do I put here to clear the value??
        //I tried box.text('') but it doesn't work
    }
     
    <input type='button' onclick='ClearBox();' />
    <telerik:RadAutoCompleteBox ID="ctrlBox"
           runat="server"
           InputType="Text"
           AllowCustomEntry="false"
           Filter="Contains"
           Delimiter=" "
           Width="630px"
           DropDownWidth="660px"
           EmptyMessage="Type here"
           OnClientDropDownOpening="openingDropdown"
           OnClientLoad="loadingAutoComplete"
           OnClientRequesting="requesting" >
    </telerik:RadAutoCompleteBox>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

    Try the following javascript.
    JS:
    function ClearBox() {
            debugger;
            var autoCompleteBox = $find("<%=ctrlBox.ClientID %>");
            var firstEntry = autoCompleteBox.get_entries().getEntry(0);
            if (firstEntry) {
                autoCompleteBox.get_entries().remove(firstEntry);
            }
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top