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

Set list of invalid characters

3 Answers 80 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jacky Chau
Top achievements
Rank 1
Jacky Chau asked on 02 May 2008, 05:57 PM
Is it possible to assign a list of invalid characters to a RadInput so the user can't even enter them into the textbox?

3 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 05 May 2008, 02:55 PM
Hi Jacky,

The requested functionality is not provided by the control out-of-the-box but you can achieve that though the client-side OnKeyPress event.

I hope this helps!

Greetings,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
tomekm
Top achievements
Rank 1
answered on 04 Mar 2010, 09:04 AM
It prevents me from using backspace or tab key on that field? Is there any work-around?
0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2010, 06:58 AM
Hello Rychu,

I also experienced same problem when I use Mozilla FireFox, its working fine in all the other browsers. A workaround for this would be check for the key code of Tab key and backspace as shown in the following approach. Give a try with this and see if it helps.

JavaScript:
 
<script type="text/javascript"
    function OnKeyPress(sender, eventArgs) { 
        var c = eventArgs.get_keyCharacter(); 
        var re = /^[a-zA-Z]$/; 
        var check = c.match(re); 
        if (check != null || eventArgs.get_keyCode() == 8 || eventArgs.get_keyCode() == 9) { 
            eventArgs.set_cancel(false); 
        } 
        else { 
            eventArgs.set_cancel(true); 
        }         
    } 
</script> 

-Shinu.
Tags
Input
Asked by
Jacky Chau
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
tomekm
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or