41
Views
9
Comments
How to restrict user to enter Alphabets and some special Characters in text input box
Application Type
Reactive

Hi Team,

Can anyone help me in restricting user to enter Alphabets and some special characters too.
I want to do on On Change . 

It would be a great help



Thanks

Hi @Sourav Sandhu ,

You can check the below component for reference :

https://www.outsystems.com/forge/component-overview/11214/reactive-client-side-validation 

Here you will find the various example.

Hope this helps.

Regards,

Manish Jawla

Champion

Hello,

If you want to avoid completely the user insert certain chars this component works very well: https://www.outsystems.com/forge/component-overview/8005/restrict-chars-reactive

Regards

Hi Saurav,

This pattern only allows the number. Call this action in onchange of Input.

Thanks

Hi

If I want to add + sign as well then what would be the regex...."^[0-9]+$". Is it like this ?

Also I don't want to highlight the input with message. Requirement is user should not even type any alphabet

Hi Sourav,

It is based on your UX.

1. If you want to prevent typing the desired characters itself on the input field you can use regex in javascript e.preventDefault or return null on change of the input action.

2. If you want to allow user to type it and validate it with a message u can follow as Mythily suggested.

Hi Sourav Sandhu ,

i saw your problem. you can try with this javascript code in javascript.

function onlyLettersAndSpaces(str) 

{  

      return Boolean(str?.match(/^[A-Za-z\s]*$/)); 


output parameter=conlyLettersAndSpaces(input parameter )


input parameter should be in text format and output parameter should be boolean.

Thanks

Prince

Hi Saurabh 

Please go with this file which I attached It will help you

Restrict Alphabets.oap

Hi ,

Try using this regex in your regex search '^[0-9][-+][0-9]+$' .


Hope it helps

Thanks

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