<?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>article Prevent user from entering Special Characters in a Text input in Power Apps Community Blog</title>
    <link>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/ba-p/894571</link>
    <description>&lt;P&gt;This question came from a post I responded to and got me thinking that this was something that may be required at times, so I came up with the model in this blog. It may have other application as well as the Text Box example.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SpecialChar.gif" style="width: 518px;"&gt;&lt;img src="https://powerusers.microsoft.com/t5/image/serverpage/image-id/246903iF01F09E155F5D673/image-size/large?v=v2&amp;amp;px=999" role="button" title="SpecialChar.gif" alt="SpecialChar.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Firstly do a Collection of all special characters (you can do this at Screen&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;OnVisible&lt;/STRONG&gt;&lt;/EM&gt;) by using their ASCII value ranges&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ClearCollect(
   colChar,
   ForAll(
      Sequence(15),
      {FieldNo: Char(32 + Value)}
   ),
   ForAll(
      Sequence(7),
      {FieldNo: Char(57 + Value)}
   ),
   ForAll(
      Sequence(5),
      {FieldNo: Char(90 + Value)}
   ),
   ForAll(
      Sequence(4),
      {FieldNo: Char(122 + Value)}
   )
)&lt;/LI-CODE&gt;
&lt;P&gt;this puts 31 Special Characters into the collection under the field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;FONT color="#0000FF"&gt;FieldNo&lt;/FONT&gt;&lt;/EM&gt;. There may be some you want to allow such as underscore _ (95) so you would have to adjust the below to suit.&lt;BR /&gt;Below is a gallery (with wrap at 4) showing the characters&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WarrenBelz_0-1618641343827.png" style="width: 400px;"&gt;&lt;img src="https://powerusers.microsoft.com/t5/image/serverpage/image-id/246902iDDA0E6F5E953E3DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WarrenBelz_0-1618641343827.png" alt="WarrenBelz_0-1618641343827.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now put this on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;OnChange&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the Text Box&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ForAll(
   colChar,
   If(
      FieldNo in Self.Text,
      Collect(
         colError,
         {CharError: true}
      );
      Reset(Self)
   )
)&lt;/LI-CODE&gt;
&lt;P&gt;NOTE - I had to use a Collection here as a Variable cannot be set inside a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;ForAll()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;statement.&lt;/P&gt;
&lt;P&gt;Put this on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;OnSelect&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the Text Box - you could also in addition put this at Screen&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;OnVisible&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Clear(colError)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Now put a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(this is the warning message) on the screen with this as the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"Do not use characters " &amp;amp; Concat(
    colChar,
    FieldNo &amp;amp; ""
) &amp;amp; " here"&lt;/LI-CODE&gt;
&lt;P&gt;and this as the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Visible&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;First(colError).CharError&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Apr 2021 06:42:50 GMT</pubDate>
    <dc:creator>WarrenBelz</dc:creator>
    <dc:date>2021-04-17T06:42:50Z</dc:date>
    <item>
      <title>Prevent user from entering Special Characters in a Text input</title>
      <link>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/ba-p/894571</link>
      <description>&lt;P&gt;This question came from a post I responded to and got me thinking that this was something that may be required at times, so I came up with the model in this blog. It may have other applications as well as the Text Box example.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Apr 2021 06:42:50 GMT</pubDate>
      <guid>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/ba-p/894571</guid>
      <dc:creator>WarrenBelz</dc:creator>
      <dc:date>2021-04-17T06:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from entering Special Characters in a Text input</title>
      <link>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/bc-p/895463#M1088</link>
      <description>&lt;P&gt;I like that. Thanks for sharing!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my cases, I would modify it to not reset the text input control. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 06:46:35 GMT</pubDate>
      <guid>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/bc-p/895463#M1088</guid>
      <dc:creator>max81</dc:creator>
      <dc:date>2021-04-19T06:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from entering Special Characters in a Text input</title>
      <link>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/bc-p/956277#M1105</link>
      <description>&lt;P&gt;Excellent article!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 13:08:27 GMT</pubDate>
      <guid>https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Prevent-user-from-entering-Special-Characters-in-a-Text-input/bc-p/956277#M1105</guid>
      <dc:creator>JR-BejeweledOne</dc:creator>
      <dc:date>2021-06-17T13:08:27Z</dc:date>
    </item>
  </channel>
</rss>

