- Home /
 
Allowing multiple dots in an input field on android
I've run into a problem with input fields on mobile. I want to make my input field allow only numbers, dots and dashes. I DON'T want the field to be limited to only one dot/dash. I'm using this code for the character validation:
 private void Start()
     {
         field.onValidateInput += delegate (string input, int charIndex, char addedChar) { return MyValidate(addedChar); };
     }
 private char MyValidate(char character)
 {
     if (character == '0' || character == '1' || character == '2' || character == '3' || character == '4' || character == '5' || character == '6' || character == '7' || character == '8' || character == '9' || character == '.' || character == '-')
     {
         return character;
     }
     else
     {
         character = '\0';
         return character;
     }
 }
 
               My settings in the inspector are:
content type: custom
line type: single line
input type: standard
keyboard type: numbers and punctuation
character validation: none 
It works in the editor, however it doesn't allow me to input more than one dot/dash on the android device. Is this a bug, or is there a way to make it work?
Your answer
 
             Follow this Question
Related Questions
Make android number pad keyboard visible for TMPro_InputField 0 Answers
How to keep opening of keyboard when focus transferred to another input field by programmatically.? 0 Answers
Disabling the inputfield above the keyboard or disable it all 0 Answers
World space InputField not behaving user friendly on Android 1 Answer
Boldface not working well on android 1 Answer