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.
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.
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
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.
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.