Hi Team,
Validation should be triggered if the user enters two consecutive dots in the text field. How can we handle this?
Discussion posts and replies are publicly visible
if( find("..", "123..456"), "ERROR", "OK" )
Thanks it works
The validation should throw an error when the user enters something like "3.6.5" as an example. how can we achive this?
In addition to the existing set of validations for decimal values, Throw a validation for values like "3.6.5".on top of this code
if( ri!txt = 0, "", if( or( not( rule!APN_isBlank(stripwith(ri!txt, "1234567890,.")) ), find("..", ri!txt) ), cons!CR_APP_FX_VALIDATION_MESSAGE[4], if( (len(ri!txt) - find(".", ri!txt)) > 9, cons!CR_APP_FX_VALIDATION_MESSAGE[3], if( ri!txt < 3.5, cons!CR_APP_FX_VALIDATION_MESSAGE[1], if( ri!txt > 4, cons!CR_APP_FX_VALIDATION_MESSAGE[2], "" ) ) ) ) )
what does 'something like this' means, is it refferring to only dots or dot between numbers ?
I assume any 2 dots should trigger an error, not necessarily 'consecutive' as mentioned in the first post?
a!localVariables( local!data: {"12345","123.45","123..45","1.2.345",null,""}, a!forEach( items: local!data, expression: todecimal(fv!item)=fv!item ) )
sid said:The validation should throw an error when the user enters something like "3.6.5" as an example
that is different than what you originally said ("two consecutive...")
it is important to be completely clear with your requirements before you post a question if you want something that will handle the various cases you require. Otherwise you'll get a solution suggestion that handles ".." but doesn't handle "3.6.5" as you've seen.
So is your requirement "can only have up to one decimal"? or is it "has to have exactly one decimal, no more and no less"? These are implemented differently, obviously.
Something I've used in the past when I need to verify exactly one period, for example, would be like <<length(split(ri!string, ".")) = 2>> meaning, if i split the string into an array of strings on the "." character, there should be exactly 2 members of the array (a part of the string before it and a part of the string after it). Note you'd need to do some extra work to ensure the other parts are numeric, if that's what you're after.
Yeah mike this worked , Thanks a lot.