For the Input I am adding validation that no non-numeric values are not allowed and only 1to 99 allowed and no -1,0,100 or any other values like "e.-+" allowed .
Text assigned with age having integer datatype
I am using below expression on input change.
But Still I am able to type this values
I dont want it to be typed value more than 1 to 99 and other characters "-.e+"
Note: I dont want to use javascript or any other forge component Will it be possible
Hi Learner,
You can probably try using the following regex - "^[1-9][0-9]?$"Note: This will allow only 1 to 99 as valid input.
Thanks,Neha Agrawal
Hi Neha,
Thanks , for Answer.
I am already using "^(?:[1-9]|[1-9][0-9])$"
But It still allowing all , I want to restrict user from entering value > than 99, and these characters".-+eE".
It should not get typed.
Yes, the reason is the regex is used in OnChange event, where you can simply override the InputValue back to null when Regex_Search.Found is False.Also, there is a HTML property named pattern ("[1-9][0-9]?"), you can try using that.There is no other way to meet your requirements without JS.Here is the full list of attributes that can be used.
Thanks,Neha
I have override the InputValue back to null when Regex_Search.Found is False But It override the value If I add more than 99 that is 100 or greater but for e,.,-,+ and 0 It wont work
Hi @New Learner ,
There are attributes you can give to the input, such as min and max and set their values to 0 and 99.
You cannot restrict a user to type in a number more than 99 but with JavaScript you can add an event listener and replace the value with 99 when user types a value more than 99.
Check OML for reference. There is a screen named Input in mainflow.
Hi @New Learner, please have a look at my component Restrict Characters, here is the link for demo.
Just type 0-9 in the first input of demo and then in the second input you can test it.
Please keep in mind that you will have to apply separate check for value less then 1 and grater then 99 because my component is only restricting the user from typing unwanted value.
One advantage is that it is complete client side logic so there is no server call.
ThanksGitansh Anand
use the below regex
regex = /^(0?[1-9]|[1-9][0-9])$/;
@New Learner I don't think you need regular expression here? I think this can be achieved simply with if condition. of course you can use the expression /[0-9]/g to only accept the numbers in input control on client side.
if age > 1 and age < 100 then proceed else return error message.
Agree with Nawaz, unless you have some requirement that did not know about it.
Yes But how to Restrict char e,.,-,+
Hello
Input mask forge component will helpful in this case
It have many properties for numeric and decimal also which will meet your requirements
Regards
Shradha
I think they used Javascript. I dont want Javascript.
@New Learner you can use the if condition on either of sides (client, server). Regular expression should also be on either of sides