restrict special charecters

2 posts, 0 answers
  1. beeta one
    beeta one avatar
    63 posts
    Member since:
    Aug 2012

    Posted 30 Nov 2012 Link to this post

    How can i restrict typing of special charecters in a radcombobox
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2012 Link to this post

    Hi,

    Please try the following Javascript to prevent user from typing particular characters.

    ASPX:
    <telerik:radcombobox id="RadComboBox1"runat="server" allowcustomtext="true"></telerik:radcombobox>

    Javascript:
    function pageLoad()
    {   
        var combo = $find("<%= RadComboBox1.ClientID %>");   
        var input = combo.get_inputDomElement();   
        input.onkeydown = onKeyDownHandler;
    }
     
    function onKeyDownHandler(e)
    {   
     if (!e)      
     e = window.event;          
     var code = e.keyCode || e.which;
     //do not allow any of these chars to be entered: !@#$%^&*()   
     if (e.shiftKey && code >= 48 && code <= 57) {
         e.returnValue = false;
         if (e.preventDefault) {
             e.preventDefault();
         }
     }       
    }

    Thanks,
    Shinu.
Back to Top