1

I want to limit the number of characters allowed in one of the questions in my ODK Xform. The question is about the user's comment so I need the field to accept any number of characters from 0 to 100 including line breaks. Otherwise it must show the proper alert.

<bind nodeset="/widgets/Comment" type="string" constraint="regex(.,'^.{0,100}$')" />

I have the above code, but it does not allow me to have line breaks, I appreciate your help.

M Reza Saberi
  • 7,134
  • 9
  • 47
  • 76

1 Answers1

2

Use the s option to make . match any character, including newlines:

<bind nodeset="/widgets/Comment" type="string" constraint="regex(.,'^(?s).{0,100}$')" />
Daniel Martin
  • 23,083
  • 6
  • 50
  • 70