Summary
In ArcGIS Survey123 Connect, a text question allows submitters to provide free text responses. It is sometimes necessary to restrict the use of certain words or characters in the text question for better data collection.
This article provides two workflows to restrict the entry of specific text values in ArcGIS Survey123 Connect.
Procedure
Depending on the suitability, use one of the following workflows to restrict the entry of specific text values in ArcGIS Survey123 Connect.
Use the regex() function
In this example, the regex() function is used to restrict the entry of commas for a text question in ArcGIS Survey123 Connect.
- In ArcGIS Survey123 Connect, open the survey's XLSForm.
- In the survey worksheet, in the constraint column of the text question, specify the expression using the regex() function to restrict the entry of specific text values.
not(regex(., "<text_value>"))
- In the survey worksheet, in the constraint_message column of the text question, specify a message to be displayed when the restricted text values are entered. In this example, the message ‘There is a comma value!’ is used.
- Save the XLSForm file.
The image below displays the constraint message when a comma value is entered in the text question in ArcGIS Survey123 Connect.
Use the pulldata() function
In this example, a CSV file containing the list of restricted words for the text question is added to the survey and the pulldata() function is used to restrict the entry of these words in the text question.
- In ArcGIS Survey123 Connect, open the survey's XLSForm.
- Create a text and hidden question.
- In the survey worksheet, in the type column, select text. Specify the values in the name and label columns as desired. In this example, the question is named ‘opinion' and labeled 'What is your opinion on deforestation?'
- In the survey worksheet, in the type column, select hidden. Specify the values in the name and label columns as desired. In this example, the question is named ‘pulldata_opinion' and labeled 'Check if the word is allowed'.
- Configure the text question using the pulldata() function.
- In the survey worksheet, in the constraint column, specify the expression using the pulldata() function to restrict the entry of specific text values.
.!=${<hidden_fieldname>}
- In the survey worksheet, in the constraint_message column of the text question, specify a message to be displayed when restricted text values are entered. The message ‘Word not allowed’ is used in this example.
- Attach the CSV file containing the list of restricted words for the text question. Refer to ArcGIS Survey123: Retrieve a value from CSV for instructions. In this example, a CSV file titled ‘restricted_words’ is used.
- Configure the hidden question. In the survey worksheet, in the calculation column, specify the expression to check if the text values entered in the text question are allowed.
pulldata('<CSV_name>', '<csv_header2>', '<csv_header1>', ${<text_fieldname>})
- Save the XLSForm file.
The images below display the constraint message when the restricted words from the CSV file are entered in the text question of the survey.