294
Views
4
Comments
restrict user to enter number and special characetrs but only letters
Question
Application Type
Reactive

Hello everyone,


im developing reactive web app. i need to restrict the user only to enter letters(first letter to be uppercase and remaining all small letters) but not numbers and special characters im using this below javascript but not working .

can someone help me here pls.


Regards.




2022-08-03 04-32-50
Ravi Punjwani

Hi Salman,

Have you tried to use any existing forge component. This is a pretty common requirement and I'm sure you would find many components to support this use case.

Here's the most popular one:

https://www.outsystems.com/forge/component-overview/7838/input-mask-react

You can try others also like

https://www.outsystems.com/forge/component-overview/11112/cleavejs

You can find many more on the forge.

2025-06-28 01-52-12
Marco Mateo

Hi salaman,

if you want to use js script instead of using or installing component. you have option to set the onkeydown event of the input.

You can test it here: https://marcomateo.outsystemscloud.com/Reactive_Experiment/RestrictCharByRegex

But there are also advantages in using component like formatting and it has some available features that you could use in your project. This is just to give you option in case you want to try your script in the future

Regards

2017-06-21 13-04-28
Mikko Nieminen

Hi,

Forge components and ways to trigger JavaScript were already mentioned, one other approach you could use is HTML pattern attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern 

Add an attribute named "pattern" to your input and enter the desired validation pattern there. Regexes can sometimes be difficult to build, so use of online tools like https://regex101.com might help a lot. Another thing not mentioned: client side validations are something advanced users can quite easily bypass, so server side validations are highly recommended.


2025-04-17 05-42-16
Ajit Kurane

Hi Salman,

In addition to above answer,

If you want first letter in Upper case then you can use below style property.


and to restrict numbers and special character you can user java script as suggested in solutions.

Thanks.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.