I would like to create an attribute rule that prevents punctuation in specific fields.
There are plenty of examples on Must Not be Null, Must Have a Record, Must have x # of characters, etc. and I am using many of them.
This solution contains a way to find characters, but what I need is for there to be an error message that alerts the user that the field should not contain certain characters.
I would like to prevent punctuation ex ".", ",", ":" (period, comma, colon) in specific fields, sometimes more than one of these and sometimes just one.
I haven't been able to find a function or an example that would help.
Solved! Go to Solution.
You could create a constraint attribute rule that tests fields for punctuation and returns an error if found—something like this where NoPuctuation is the name of the attribute you are trying to constrain.
var testVal = $feature.NoPuctuation
if (Find (",", testVal) > -1)
return {"errorMessage": "Comma Found."}
else if (Find (".", testVal) > -1)
return {"errorMessage": "Period found."} //asas
else if (Find (":", testVal) > -1)
return {"errorMessage": "Colon found."}
else
return true;
You could create a constraint attribute rule that tests fields for punctuation and returns an error if found—something like this where NoPuctuation is the name of the attribute you are trying to constrain.
var testVal = $feature.NoPuctuation
if (Find (",", testVal) > -1)
return {"errorMessage": "Comma Found."}
else if (Find (".", testVal) > -1)
return {"errorMessage": "Period found."} //asas
else if (Find (":", testVal) > -1)
return {"errorMessage": "Colon found."}
else
return true;