How can I make an input field only take in numbers and decimals?

I want to make an ip input field… how can I disable any other characters?

You could check the string the user entered contains stuff you don’t want after every character input via…

myString.Contains("a")

and then, if yes, immediately delete it.

via…

myString = myString.Remove(myString.length - 1);

You’ll need a lot of checks for all sorts of characters, though.

a faster way would be to iterate through the string and remove a character if it is not 1,2,3, if the set of characters you allow is smaller than the set of characters you disallow.