How to validate ssn in appian? format should be ###-##-####
Discussion posts and replies are publicly visible
I think this would be a good case for the regular expression plugin.
can we use regex in a!textfield()
You can use regex pattern matching in any place you'd use other expression logic. In this case, Stefan is referring to using it in the text field's "validations" parameter.
i am creating a form. user needs to fill the ssn field. if he enters other than this ###-##-####, it should throw validation message.
i am not sure, but am using like this:
validations: {regexmatch("^\d{3}-\d{2}-\d{4}$"),ri!SR_Test.ssn}
its showing an error "Unexpected number of parameters"
Your expression is not formatted correctly.
First, "validations" expects one or more strings. These strings will be shown as [failed] validation message(s) anytime they're present - meaning you would need to show the strings conditionally, something like this:
validations: { if( [validation failure condition #1], "Validation Message 1", {} ), if( [validation failure condition #2], "Validation Message 2", {} ), [etc] }
1/
Second, "regexMatch" expects at least 2 parameters, pattern then search string. You're only passing in the pattern, and then your search string is not even included in the function call.
The correction to this is fairly simple:
regexmatch( "^\d{3}-\d{2}-\d{4}$", ri!ssn )
...which seems to work fine per what you're after. Please note also that "regexMatch()" returns values of TRUE or FALSE, so you'll want to only show your validation message when the match operation returns a FALSE.
(When you have this part down, I'd note that there are some heuristic validations for SSN's which you might want to eventually include - such as, no section of the SSN is allowed to be all zeros, the first digit can't be "9", etc.)
2/2
Hi Mike,
On the Similar note , can you please explain the symbols being used in regex functions? I am referring to the below link but this doesn't explain greatly on the use of The cap symbol (^) and the dollar one and the brackets . It'll be really helpful if you can explain a bit on those by any example.
https://community.appian.com/b/appmarket/posts/regular-expression-functions
Appian uses relatively standard Java Regex syntax - there are plenty of tutorials and primers available externally. Here's one I keep bookmarked for a quick reference every time I need to brush up and try to accomplish something new within Appian: www.vogella.com/.../article.html
Okay!! Thank you Mike
Mike Schmitt said:which you might want to eventually include -
how this will be achieve in appian
for example: 345 - 34 -5467
After entering 345 "-" should populate automatically before entering next number
Chaitra R said:after entering numbers. can we do that??
Can you do what?