- Home /
How to restrict different characters in different text fields?
I want to restrict what characters can be used in each GUI.textfield separately. I would like the user to only be able to input numbers in one field and the only numbers letters and spaces in the field below it.
I have used the following code, but it applies to every textfield and I cannot allow spaces to be used. I am trying to do this for some sort of form validation. The user inputted data will be going to a PHP page to modify my database and I want to avoid any kind of code injection. Plus I want to calculate whether the numbers inputted will work client-side.
if ( !char.IsLetterOrDigit(chr) )
{
Event.current.character = 0;
}
I understand that regex is taxing on web clients, so I would rather avoid that if I can.
Thanks in advance.
Comment