Not applicable

Re: Validation for special characters on column

Jump to solution

Thanks Core. Your answer help me.

Have a nice day.

0 Kudos
Reply
kmccool
Scholar

Re: Validation for special characters on column

Jump to solution

I am trying to achieve this same goal in a Multi line text field on my form.

I do not have a location for regex in the field settings and when I try to create a validation rule, if I add more than one "contains" function, it does not error.

works:

contains({Self},"&")

Not working:

contains({Self},"&")||contains({Self},"#")||contains({Self},"$")

or(contains({Self},"&"),contains({Self},"#"),contains({Self},"$"))

I also tried a custom validation in the field settings:

fn-Contains($,#,%)

Any ideas on how I can achieve an error message when special characters are used?

I guess I could just add 18 separate rules for each character I'm trying to avoid but it seems crazy.

Thanks

Kassie

0 Kudos
Reply
MegaJerk
Collaborator

Re: Validation for special characters on column

Jump to solution

your second example should totally work. 

Tested it in my environment (inside of a validation rule for a Multi Line Text control) and it worked as expected. 

contains({Control:Self},"!") || contains({Control:Self}, "@")

However, if you just wanted to use regex, you could get away with using an Immediately Invoking Function Expression in your rule. 

Rule Formula: 

(function(currentValue){
return currentValue.match(/[^\w\s\.\,]/g) !== null;
}({Control:Self}))‍‍‍

Example Picture (ignore the code in the picture. use the rule formula as shown above): 


This will return true (or invalid) anytime a character that isn't: 

  • a through z

  • A through Z

  • 0 through 9

  • _

  • whitespace (space)

  • .

  • ,

If you want to add more valid characters you can simply include them after the comma, or somewhere between the [^ ]

I hope that this helps. 

Reply
kmccool
Scholar

Re: Validation for special characters on column

Jump to solution

I think there's a problem with:

|| contains({Control:Self}, "\")

when I add that to the rule, it doesn't validate.

but yea, it works if I leave that one out.

Thanks

Kassie

0 Kudos
Reply
anthonynhn999
Novice

Re: Validation for special characters on column

Jump to solution

I can replicate your issue, and this is caused by the 2 special characters: < >

As a work-around, you should treat these 2 characters in a special way, e.g. using a Nintex rule (function contains) to handle them. The rest of the other special characters should be ok.

0 Kudos
Reply