RadNumericTextBox - OnKeyPress is too early

4 posts, 0 answers
  1. Kevin Schneider
    Kevin Schneider avatar
    48 posts
    Member since:
    Jan 2008

    Posted 05 Jun 2008 Link to this post

    I have a situation where I need to have a numeric textbox hide/show a division on the page based on whether or not it is empty.  I can't do it onblur / onvaluechanged since it needs to be real-time while they are typing.

    I can't use onkeypress either since it is too early and I can't use isEmpty() to validate that the textbox is empty or not.

    What client event is available for this?

    Thanks.
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 06 Jun 2008 Link to this post

    Hello Kevin,


    You can use the onkeyup event handler. The onkeyup event occurs when a keyboard key is released.

    The following code example demonstrates how to achieve your goal:

           <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
            <div> 
                <script type="text/javascript"
                function keyup() 
                { 
                    var radTextBox = $find("RadTextBox1"); 
                    if (!radTextBox.get_textBoxValue()) 
                    { 
                        Sys.Debug.trace("Empty!"); 
                    } 
                    else 
                    { 
                        Sys.Debug.trace("Not Empty!") 
                    } 
                     
                } 
                </script> 
                         
                <telerik:RadTextBox onkeyup="keyup()" ID="RadTextBox1" runat="server"
                </telerik:RadTextBox> 
                 
                <textarea id='TraceConsole' rows="10" cols="50" title="TraceConsole"
                </textarea>             
            </div> 



    Kind regards,
    Plamen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. jrit
    jrit avatar
    16 posts
    Member since:
    Jun 2006

    Posted 01 Oct 2009 Link to this post

    I have the same question, but I'm in an up to date version of AJAX controls. The solution proposed works the same as OnKeyPress, so is not effective.
  4. Dimo
    Admin
    Dimo avatar
    8450 posts

    Posted 02 Oct 2009 Link to this post

    Hi Jarrett,

    I tested the above code with the latest version of RadControls and it worked as expected. Please send us a sample page.

    Kind regards,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top