HOW TO RETURN A NOTE ERROR WHEN INPUTTING AN INVALID CHARACTER

629
3
09-30-2022 12:25 AM
jantolihao
Occasional Contributor

Hello everyone!

I am new to ArcGIS Survey123 Connect. I have a hidden field {charac} which contains characters in the default column. I used the function regex (., ${charac}) as constraint in the {name} field to prevent users from inputting characters in the {charac} field.

jantolihao_1-1664516532086.png

Question is, how to trigger an error note and code it in the relevant column the moment users include those invalid characters as input in the {name} field?

For example:

An error note "Error: The name field contains invalid characters!" will appear once a sample input "MARIA'S. CRUZ" (with invalid characters: apostrophe and period) is inputted in the name field.

I appreciate any hints or ideas on this. Thank you very much in advance.

 

0 Kudos
3 Replies
ChristopherCounsell
MVP Regular Contributor

Not sure why you have a hidden question. You can just include the values in the constraint expression. 

For the 'name_' question:

  • Add a regex constraint listing the values e.g. for  ' \ & @ ; " / ? + # $
    not(regex(.,'[|\x27|\x5C&@;"/?+#$]'))
  • Another example, limit the range of input characters to letters by adding the below to the constraint column:
    regex(.,'^[A-Za-z]*$')
  • Add a constraint message saying "Please do not input special characters"

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION2_BED1A39...

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_8979CBF...

Also noted you have renamed the name field to 'name_'. Would definitely recommend just a better field name that is not 'name' as it's a reserved word, and affixing '_' isn't the best fix...

0 Kudos
jantolihao
Occasional Contributor

Hello. Thank you very much for replying.

I also tried your suggestion not(regex(.,'[|\x27|\x5C&@;"/?+#$]')) before since I read this from other users as well. However, it doesn't seem to work in my end. So, I decided to use a different approach and it's actually working.

I already used constraint before. However, if I'm not mistaken, the user will only be able to see the constraint message when you click the submit button.

In my case, I want the error message to appear before the user proceeds to the next field in the form, and not during the submission of the form after filling out all the fields.

I have this idea in my mind to use an if statement in the relevant column, but I can't seem to form any. If you have any suggestion, I appreciate any hints. Thank you very much.

0 Kudos
Alfred_Baldenweck
New Contributor II

@DougBrowning has an excellent guide to getting real-time notifications of errors.

It does require a few extra, hidden questions, but it works great. 

How to simulate instant data checking using emojis - Esri Community