New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Prevent from Typing Particular Characters

One of the limitations of the OnClientKeyPressing event is that it cannot be cancelled. This means that the user can type any letter in the input area of the RadComboBox (when AllowCustomText is set to True).

This example will show you how to disallow the user to type any of the following letters in the input area of the combo: !@#$%^&*()


Add the following javascript code which will handle any keydown event on the input area and will cancel it by returning false (Internet Explorer) or preventing the default action (Firefox):

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) {

See Also

In this article