How to accept only numbers and special characters including for input with type Text

I have been trying to read especial character and throw error “Please enter a number” if we enter special characters like “e”

Initially I tried with input type as number which don’t recognized “E” so unable to validate input being typed.

Now I have switched back to “Text” but issue is it read other alphabets as well and letting type “E/e/+/-” multiple times which is not the case when it was number.

In a nutsell, I want input type “Text” to behave as “Number” type with ability to read all characters

Have you looked into using a callback with a Regex check?

I tried regex, problem is that it is still letting me type ‘e’ more than one as its getting stored in state, I wanted to type only e and ignore other alphabet, Even e I want to type only once

This should work, you have to type E, but you can just make it 10E0 if you want “10”

r'^([0-9]+)E([0-9]+)$'