RadComboBox OnClientKeyPressing

4 posts, 1 answers
  1. Shan
    Shan avatar
    1 posts
    Member since:
    Aug 2012

    Posted 03 Aug 2012 Link to this post

    I am trying to restrict users entering Regular Expression value like  <%^>/   in RadComboBox while typing  but it throws error message "Object doesn't support this property or method" 

    I want to validate it while typing in RadComboBox.

    function OnClientKeyPressing(sender, args) {
    if(checkRegEx())      // checking the RegEx value, if pass then proceed else remove the last character entered  
    // Proceed.......
    args.set_cancel(true);  // ERROR : Object doesn't support this property or method 


    <telerik:RadComboBox ID="rcbMonthEndDate" Runat="server" TabIndex="5"
    DropDownWidth="100px" MarkFirstMatch="true" AllowCustomText="true" EnableLoadOnDemand="false"
       HighlightTemplatedItems="true" OnClientKeyPressing="OnClientKeyPressing" 
       NoWrap="true" EmptyMessage="Select Date" AutoPostBack="False"
       Enabled="true" Width="100px"    
       DataTextField="MonthEndDate" DataTextFormatString="{0:yyyy-MM-dd}" 
                                    <%# DataBinder.Eval(Container.DataItem, "MonthEndDate", "{0:yyyy-MM-dd}")%>
    <ExpandAnimation Type="OutBounce" />
    <CollapseAnimation Type="InBack" />                            

  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2012 Link to this post

    Hi Shan,

    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). Please take a look into this for more information.

    Hope this helps.

  3. Velkumar
    Velkumar avatar
    16 posts
    Member since:
    Jul 2012

    Posted 29 Sep 2014 in reply to Princy Link to this post

    Hi Princy,

    Is there a way to avoid postback when enter key is pressed in radcombobox? in my below code if user gives enter without enter any value, i need to give a alert.

    alert is working fine, but the problem is page is getting postbask, i don't want that. How to resolve this??

      function productComboBox_OnClientKeyPressing(sender, eventArgs) {
                if (eventArgs.get_domEvent().keyCode == 13) {
                    var combo = sender;
                    if (combo.get_text().trim() == "") {
                        alert("Please enter part or all of an item description");

      <telerik:RadComboBox ID="productComboBox" runat="server" ClientIDMode="Static" CssClass="DetailsInput"
                                                EnableEmbeddedSkins="true" Skin="Metro" AllowCustomText="true" AutoPostBack="false"
  4. Nencho
    Nencho avatar
    1876 posts

    Posted 02 Oct 2014 Link to this post

    Hello Velkumar,

    In order to achieve the desired functionality, I would suggest you to prevent the propagation of the event, when the keyCode is 13, using jQuery in the following manner :

    <script type="text/javascript">
                function pageLoad() {
                    $telerik.$(".rcbInput").on("keyup", function (e) {
                        if (e.keyCode == 13) {
                            var combo = $find("productComboBox");
                            if (combo.get_text().trim() == "") {
                                alert("Please enter part or all of an item description");


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top