Restrict text field by two words only

438
2
Jump to solution
03-01-2023 06:37 AM
SoratoMarques
New Contributor III

Hi,

I would like restrict the user to input in a text field until 2 words, separeted by comma.

It´s possible in survey connect 123?

Eg. Car Cat = Correct (2 words and 1 space)

Car Cat Ball = Wrong (3 Words inputed)

Thank´s

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

A couple of ideas:

  • Use a regular expression in the constraint column. For example regex(${input_text},".[,].") 

IsmaelChivite_0-1677700707114.png

  • Use a custom JS function to define the logic of your text evaluation. For example, you could use split on your input text to check if the array with a comma separator has two entries

IsmaelChivite_1-1677701066603.png

 

Attaching both options so you can see them in action. Start with the RegEx one. It is simpler. 

If not familiar with custom JS, check this: https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js/b... 

View solution in original post

2 Replies
IsmaelChivite
Esri Notable Contributor

A couple of ideas:

  • Use a regular expression in the constraint column. For example regex(${input_text},".[,].") 

IsmaelChivite_0-1677700707114.png

  • Use a custom JS function to define the logic of your text evaluation. For example, you could use split on your input text to check if the array with a comma separator has two entries

IsmaelChivite_1-1677701066603.png

 

Attaching both options so you can see them in action. Start with the RegEx one. It is simpler. 

If not familiar with custom JS, check this: https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js/b... 

SoratoMarques
New Contributor III

Hi Ismael.

I will try. Very interesting!!

Thank´s for your help.

0 Kudos