RadInput - automatic postback after reaching maxlength

2 posts, 0 answers
  1. Roel
    Roel avatar
    13 posts
    Member since:
    Dec 2007

    Posted 01 Aug 2008 Link to this post

    Hi,

    Is there a way to have a client-side postback when the input in a textbox reaches the maximum length?

    The input is generated by a bar-code scan, but unfortunately the scanner can't be configured to trigger a carriage return after input.

    Thanks,
    Roel

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Aug 2008 Link to this post

    Hi Roel,

    You can try the following code snippet to achieve the desired scenario.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1"  runat="server" Width="640px"   ClientEvents-OnKeyPress ="test" > 
            </telerik:RadTextBox> 

    JS:
    <script type="text/javascript"
    function test() 
     var maxLength = 5
     var txt=document.getElementById("<%= RadTextBox1.ClientID %>"); 
     if(txt.value.length==maxLength) 
      { 
     
         __doPostBack("<%= RadGrid1.ClientID %>"); 
       } 
    </script> 


    Hope this helps
    Shinu.
Back to Top