Allow user only put numbers on input widget

Hello,

I have an input widget where's the data type is text but i only want to type numbers (0-9). I am trying to use the onekeypress event using a javascript code, but i am not able to managed it. Some help?


I am using data type text on the widget input because i want to save records with the 0 value

Hi Pedro,

Besides what Paulo just suggested you can also achieve this with JS.

Please see this link for more detail.

Hope this helps,

Pedro

Solution

hey,

you can use regax for better experience on input change

You can add reference for regax search from text in manage dependencies.and use below regax pattern to allow number only 

"^(0|[1-9][0-9]*)$"

Hope this will help you

Thanks

Yogesh


Hello Pedro , 

You can achieve this by using a mask on your input. 

Take a look at this forge component .

Hope it helps !

Paulo Rosário

Hi Pedro,

Besides what Paulo just suggested you can also achieve this with JS.

Please see this link for more detail.

Hope this helps,

Pedro

Solution

hey,

you can use regax for better experience on input change

You can add reference for regax search from text in manage dependencies.and use below regax pattern to allow number only 

"^(0|[1-9][0-9]*)$"

Hope this will help you

Thanks

Yogesh


Hi Pedro Ricarte,

I have added oml file Please check.

Allow Numeric Value

Thanks,

Vipin Yadav

AllowNumericValue.oml

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