RadInputManager - HTML in Textboxes

3 posts, 1 answers
  1. Amar
    Amar avatar
    21 posts
    Member since:
    Oct 2008

    Posted 11 Feb 2009 Link to this post

    Hi

    Is there a way of preventing the < > characters being entered in RadTextbox. I tried implementing a new control derived from the RadTextbox but the radtextbox renders a span as the outer control so i could not consume the onkeypress events etc.

    Then i looked at the control suite and found that RadInputManager might do the job. But i have been unable to construct a regular expression which will ensure that the brackets <> are not allowed in the textboxes.

    Can anyone help please.

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

    Posted 13 Feb 2009 Link to this post

    Hi Amar,

    Please try the below code to disallow the  < > characters being entered in RadTextb

    <div> 
            <script language="javascript" type="text/javascript">  
            function RadTextBox1_KeyPress(sender, args) 
            { 
                if (alphaNumericCheck(args.KeyCharacter)) 
                { 
                    return true; 
                } 
                else 
                { 
                    sender.RaiseErrorEvent(); 
                    return false; 
                } 
            } 
             
            function alphaNumericCheck(val) 
            { 
                var regex=/^<>/;  
                if(regex.test(val)) 
                { 
                    return true; 
                }  
                else  
                { 
                    return false; 
                } 
            } 
            </script>  
            <rad:RadTextBox ID="RadTextBox1" runat="server">  
                <ClientEvents OnKeyPress="RadTextBox1_KeyPress" />   
            </rad:RadTextBox>  
            </div> 



    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Amar
    Amar avatar
    21 posts
    Member since:
    Oct 2008

    Posted 19 Feb 2009 Link to this post

    hey thanks for the code, i will see if it can achieve what i want. Right now the code you posted works for single textbox and you have to assign it to the onkeypress event of the textbox. I wanted to do it using the input manger which lets you specify one filter expression and add multiple textboxes to that.

    anyways, i think your code will do what i want, as i could simply extend the radtextbox and subscribe to the onkeypress event by default.

    Thanks.
Back to Top