Numeric TextInput

I’m trying to implement a numeric textbox, but I’m having some issues.
I’ve successfully implemented a method to activate on ValueChanged which separates out the new text and then figures out wether it contains any illegal characters.
The problem is when I’m trying to change the TextInput.Value to the legal string:

textInputA.SetValue(legalText, textInputA);

It crashes the program with an error saying:

System.ArgumentOutOfRangeException: Index and Length must refer to a location within the string.
Parameter name: Length

Whenever the legalText.Length != textInputA.Value.Length

The reason for why I want to use SetValue is that I can then filter out any ValueChanged events caused by the code changing the value, from any events caused by the user typing.

User typing:

args.Origin = null

textInputA.SetValue(legalText, textInputA):

args.Origin != null

So then it’s only a matter of a simple if test:

if (args.Origin == null)

Is origin the name of your TextInput?

TextInput does not have Property called Text, but rather Value.

origin.Value = "Some very old text";

Yes, this post dates back to before the latest update, so the names have changed a bit, I’ve now updated my post.

Did you know you can make a TextInput pop up a numeric keyboard on mobile using InputHint="Number"?

I was looking for that earlier. Although my app will also run on WebGL so I will probably still need the filter for Web users.