diff --git a/knowledge-base/combobox-prevent-numeric.md b/knowledge-base/combobox-prevent-numeric.md new file mode 100644 index 000000000..63be9ff72 --- /dev/null +++ b/knowledge-base/combobox-prevent-numeric.md @@ -0,0 +1,65 @@ +--- +title: How to Restrict Numeric Input in ComboBox +description: Learn how to prevent users from typing numbers in a Telerik UI for Blazor ComboBox. +type: how-to +page_title: How to Prevent Numeric Input in Blazor ComboBox +slug: combobox-kb-prevent-numeric +tags: combobox, blazor, input, numeric +res_type: kb +ticketid: 1682510 +--- + +## Environment + + + + + + + + +
ProductComboBox for Blazor
+ +## Description + +I want to restrict typing numbers in the [`ComboBox`](slug:components/combobox/overview) component. + +## Solution + +To prevent users from entering numbers in the ComboBox: + +1. Wrap the component in an HTML element and use the [`onkeydown` event](https://www.w3schools.com/jsref/event_onkeydown.asp) to capture every keystroke. +2. Implement a JavaScript function that prevents the numbers. + +Below is the implementation: + +`````RAZOR +
+ + +
+ + + +@code { + private string? ComboValue { get; set; } + + private List ComboData { get; set; } = new List { + "Manager", "Developer", "QA", "Technical Writer", "Support Engineer" + }; + + private void OnComboValueChanged(string newValue) + { + ComboValue = newValue; + } +} +`````