<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to trim white space in a text field? in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/how-to-trim-white-space-in-a-text-field/m-p/1466614#M56858</link>
    <description>&lt;P&gt;I have a survey with many questions including two text fields. These two text fields must contain between 5 and 250 characters. Some users add a blank space to reach 5 characters. For example, they enter "Stop " then I have to modify their entry to meet the 5 character minimum requirement. I need to validate all data before submitting.&lt;/P&gt;&lt;P&gt;I'd like to trim white space and base the minimum character count on the resulting string. I've created a survey with some JavaScript that does this, but the JavaScript doesn't get called at the right time and the constraint doesn't work.&lt;/P&gt;&lt;P&gt;I've attached an XLSForm and a JavaScript file. (JSUtils.txt needs to be renamed to JSUtils.js.) Does anyone know how to get this to work? Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2024 17:09:55 GMT</pubDate>
    <dc:creator>ChuckS</dc:creator>
    <dc:date>2024-05-14T17:09:55Z</dc:date>
    <item>
      <title>How to trim white space in a text field?</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/how-to-trim-white-space-in-a-text-field/m-p/1466614#M56858</link>
      <description>&lt;P&gt;I have a survey with many questions including two text fields. These two text fields must contain between 5 and 250 characters. Some users add a blank space to reach 5 characters. For example, they enter "Stop " then I have to modify their entry to meet the 5 character minimum requirement. I need to validate all data before submitting.&lt;/P&gt;&lt;P&gt;I'd like to trim white space and base the minimum character count on the resulting string. I've created a survey with some JavaScript that does this, but the JavaScript doesn't get called at the right time and the constraint doesn't work.&lt;/P&gt;&lt;P&gt;I've attached an XLSForm and a JavaScript file. (JSUtils.txt needs to be renamed to JSUtils.js.) Does anyone know how to get this to work? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 17:09:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/how-to-trim-white-space-in-a-text-field/m-p/1466614#M56858</guid>
      <dc:creator>ChuckS</dc:creator>
      <dc:date>2024-05-14T17:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim white space in a text field?</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/how-to-trim-white-space-in-a-text-field/m-p/1473211#M56902</link>
      <description>&lt;P&gt;I found a solution that doesn't use JavaScript. I added a regular expression to the constraint to get the behavior that I'm looking for. Here's the whole constraint.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;string-length(.)&amp;gt;=5 and string-length(.)&amp;lt;=250 and not(regex(., '(^[a-zA-Z0-9.-]{3,4}[ ]{1,2})|(^[ ]{1,2}[a-zA-Z0-9.-]{3,4})') and string-length(.) &amp;lt;= 6)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks complicated, but it simply checks for two patterns:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;3 or 4 characters followed by 1 or 2 spaces.&lt;/LI&gt;&lt;LI&gt;1 or 2 spaces followed by 3 or 4 characters.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This essentially trims the white space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 21:29:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/how-to-trim-white-space-in-a-text-field/m-p/1473211#M56902</guid>
      <dc:creator>ChuckS</dc:creator>
      <dc:date>2024-05-15T21:29:04Z</dc:date>
    </item>
  </channel>
</rss>

