Set list of invalid characters

4 posts, 0 answers
  1. Jacky Chau
    Jacky Chau avatar
    108 posts
    Member since:
    Jun 2005

    Posted 02 May 2008 Link to this post

    Is it possible to assign a list of invalid characters to a RadInput so the user can't even enter them into the textbox?
  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 05 May 2008 Link to this post

    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
  3. tomekm
    tomekm avatar
    38 posts
    Member since:
    Mar 2009

    Posted 04 Mar 2010 Link to this post

    It prevents me from using backspace or tab key on that field? Is there any work-around?
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2010 Link to this post

    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.
Back to Top