I am developing an ASP.NET MVC3 application and i am using telerik ComboBox in it. I have a requirement wherein i have to disable the Enter button click in the ComboBox because it is trigerring the form submit method. Below is the code i have
Html.Telerik().ComboBox().Name("OpportunityType").Value("-1")
.BindTo(new SelectList(Model.OpportunityTypes, "OpportunityID", "OpportunityTypeName"))
.ClientEvents(events => events.OnChange("OnOpportunityTypeChange")
)
.HtmlAttributes(new { style = "width: 180px;" }).Render();
i have tried to handle the key press event of the dropdown with as below in document.ready of jquery, but even that didn’t solve the purpose. Do we have a keypress event for Telerik ComboBox? my code never reaches there on enter click i tried to alert some value and it didn’t show up
$("#OpportunityType").keypress(function (e) {
if (e.which == 13 || e.keyCode == 13) {
return false;
}
});
any other way to disable the enter key event for this combobox?
You should add the handler to the input element – not the hidden one.
i.e.
I hope this helps !