title: PowerApps: How to get Text-Input onChange to trigger updating the text?
body: <p>I have a text box that accepts phone numbers.  I want to automatically strip any special characters that aren't a + from the input, and show the user that I've done so.</p>
  
  <p>I've tried this, but I'm not even seeing any onChange event fire, let alone actually updating my data.</p>
  
  <p>In my OnChange for the text-input, I have this:</p>
  
  <pre><code>Substitute(cvarNumberE164ValueNew,"(","");
  Substitute(cvarNumberE164ValueNew,"-","");
  Substitute(cvarNumberE164ValueNew,".","");
  Substitute(cvarNumberE164ValueNew," ","");
  
  UpdateContext({cvarNumberE164ValueNew : cvarNumberE164ValueNew});```
  </code></pre>
  
  <p>The logic here is "replace these 5 common characters in a phone number, and then trigger UpdateContext which is supposed to trigger the field to re-get the value".</p>
  
  <p>Obviously I'm not doing something properly, but can't figure out what.  I've also tried repeatedly firing UpdateContext to set <code>cvarNumberE164ValueNew</code> to be the result of the Substitute functions, to no avail.</p>
  
  <p><strong>Edit</strong>
  I have this working now, but it ended up being a bit convoluted.  I had to initialize and set a global variable in the OnChange of the text input.  Then do all my substitutions against that variable, and finally, do the UpdateContext to set my Context Variable with the value of the global one. The Default property of my text input is cvarE164Value, so at least PA's data handling auto-updates the text input after all this.</p>
  
  <p>To clean up, I set the global variable back to an empty string, so the logic can repeat itself reliably if users repeatedly edit the field with data I want to prune and so it doesn't persist to their previous value if they go to the form again later in the same session..</p>
  
  <pre><code>Set(gvarNumberE164ValueNew,txtNumberE164ValueNew.Text);
  
  /* prune ) */
  Set(gvarNumberE164ValueNew,Substitute(gvarNumberE164ValueNew,")",""));
  
  /* prune ( */
  Set(gvarNumberE164ValueNew,Substitute(gvarNumberE164ValueNew,"(",""));
  
  /* prune - */
  Set(gvarNumberE164ValueNew,Substitute(gvarNumberE164ValueNew,"-",""));
  
  /* prune - */
  Set(gvarNumberE164ValueNew,Substitute(gvarNumberE164ValueNew,".",""));
  
  /* prune SPACE */
  Set(gvarNumberE164ValueNew,Substitute(gvarNumberE164ValueNew," ",""));
  
  /* replace cvar with cleaned gvar */
  UpdateContext({
    cvarE164Value : gvarNumberE164ValueNew
  });
  
  Set(gvarNumberE164ValueNew,"");```
  </code></pre>