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

restrict special charecters

1 Answer 110 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
beeta one
Top achievements
Rank 1
beeta one asked on 30 Nov 2012, 07:50 AM
How can i restrict typing of special charecters in a radcombobox

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Nov 2012, 07:58 AM
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.
Tags
ComboBox
Asked by
beeta one
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or