Validate on extra Spaces in Survey 123 connect

502
3
03-31-2022 04:41 AM
Kristofer
New Contributor III

Hi,

Is there a way of formula to avoid the extra spaces or validation on extra spaces.

For Example

Question- Name of the Employee

Answer - Sunita   Kaushik  (Here are 3 spaces between Sunita and Kaushik)

I want to validate this. when user will answered like this (with extra spaces) Survey form will not be submitted.

Regards,

Sunita

 

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

By using regex in the constraint column, you can get your survey to check for a single space.

In its simplest version, you can try ^\w+\b\s\w+$. This will match a first name and a last name, separated by a single space.

jcarlson_0-1648730756387.pngjcarlson_1-1648730767662.png

 

To get this expression to catch names with 3 or more (or even 1) parts, you can use grouping. The expression ^\w+(\b\s\w+)*$, which will look for 0 or more instances of words following the first. This will allow your form to take all kinds of names, while still ensuring that only single spaces occur between the various parts of the name.

jcarlson_2-1648731033933.pngjcarlson_3-1648731062212.png

 

- Josh Carlson
Kendall County GIS
DeonLengton
Esri Contributor

Hi Sunita

You can use a regex expression in the constraint column to check for this:

regex(${<fieldname>}, "[ ]{2,}")=false()

Then add a message in the constraint_message column to notify the user.

Hope that helps

Kristofer
New Contributor III

Hi DeonLengton,

Thank you very Much. This is Working Fine.

Regards,

Sunita

0 Kudos