RadzenTextBox onkeypress function javascript


from the onkeypress event of a RadzenTextBox is it possible to call a javascript function that allows only some letters and numbers? How could I do it?

Thank you very much in advance.

Here is an example to allow only numbers:

<RadzenTextBox onkeypress="(function (e) { if (!/^[-\d]$/.test(String.fromCharCode(e.charCode))) { e.preventDefault(); } })(event)" />

you can adjust the regular expression to your case.

It works! Thank you!