Hi All,
I have a requirement where i have to add validation on a text field and the validation is like + and three integer.
please help me out with this.
thanks.
Discussion posts and replies are publicly visible
You can use the code below for it.
and( len(ri!text)<=4, a!forEach( items: code(ri!text), expression: or( fv!item=43, and( fv!item>=48, fv!item<=57 ) ) ) )
Here is another variant of it where the first character has to be a "+"
and( len(ri!text)<=4, a!forEach( items: code(ri!text), expression: if( fv!isFirst, fv!item=43, and( fv!item>=48, fv!item<=57 ) ) ) )
The below code also should work. If the first character has to be a "+" and the rest should be three number digits
regexmatch( "^\+([0-9]{3})$", ri!text )
Note the regexmatch() solution does require to install the Regular Expressions Functions plugin. Otherwise there are a number of ways to do this OOTB. Another example:
and( len(ri!text)=4, code(left(ri!text,1))=43, tointeger(right(ri!text,3))=right(ri!text,3) )