This is a migrated thread and some comments may be shown as answers.

RadInputManager - HTML in Textboxes

2 Answers 105 Views
Input
This is a migrated thread and some comments may be shown as answers.
Amar
Top achievements
Rank 1
Amar asked on 11 Feb 2009, 10:41 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Feb 2009, 06:03 AM
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.
0
Amar
Top achievements
Rank 1
answered on 19 Feb 2009, 11:46 AM
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.
Tags
Input
Asked by
Amar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Amar
Top achievements
Rank 1
Share this question
or