I need to restrict input in the combobox so that it only allows the numbers 0-9 and the backspace key. I have tried the code here and here. The code works in IE, but not in Firefox 3.5.
| <telerik:RadComboBox ID="RadComboBox1" runat="server" |
| EnableLoadOnDemand="true" |
| AllowCustomText="true" |
| AutoPostBack="true" |
| OnItemsRequested="RadComboBox1_ItemsRequested" |
| OnTextChanged="RadComboBox1_TextChanged" |
| HighlightTemplatedItems="true" > |
| <ItemTemplate> |
| <div><%#DataBinder.Eval(Container, "Text") %></div> |
| <div><%#DataBinder.Eval(Container, "Attributes['Name']")%></div> |
| <div><%#DataBinder.Eval(Container, "Attributes['Number']")%></div> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
| function pageLoad() { |
| var combo = $find("<%= RadComboBox1.ClientID %>"); |
| var input = combo.get_inputDomElement(); |
| input.onkeydown = ComboBoxKeyDownHandler; |
| } |
| function ComboBoxKeyDownHandler(e) |
| { |
| if (!e) |
| e = window.event; |
| var code = e.keyCode; |
| //only allow 0 through 9 or backspace to be entered |
| if (!((code >= 48 && code <= 57) || (code == 8))) |
| { |
| e.returnValue = false; |
| if (e.preventDefault) |
| { |
| e.preventDefault(); |
| } |
| } |
| } |