I need the text field to show only certain characters that the user types. Besides, I want the text in the text field to be of certain pattern, for example, (###) ###-####, where # represents a digit. After the pattern is matched, the rest of what the user types will also be accepted. The pattern is not fixed, it can also be something like: ###/###-####. But I can provide the pattern. Is this possible?
Asked
Active
Viewed 232 times
1
-
definitely possible ! but some examples or sample i/o should be provided . – roy Sep 05 '17 at 04:28
-
user can only fill **(###) ###-####** pattern (or other) in `textfield` or along with pattern they can write anything in the same `textfield` ?? – dahiya_boy Sep 05 '17 at 04:28
-
see this https://stackoverflow.com/questions/6052966/phone-number-formatting – Anbu.Karthik Sep 05 '17 at 04:48
-
I will get a phone mask for the pattern. I do not know before-hand what it is. I think I need to separate the # characters (which are digits from 0 to 9) and non-# characters, and record the locations of the non-# characters. As the user types, I need to take account of how many #s have been entered and insert the non-# characters at the right locations. After the pattern is exhausted, whatever the user types will still be accepted. For example, for the pattern (###) ###-####, if the user types (123) 456-7890 ext. 123, it will be accepted. The link that Anbu.Karthik is definitely helpful. – Wei Wen Sep 05 '17 at 16:06
-
What I said phone mask is basically the pattern I want the text field to show. It can be (###) ###-####, or ###-###-####, or ###/###-####, or any pattern that can be specified in another place, but not in the app. In addition to iOS, I wonder if there is a similar method I can overwrite in Android? I also need to do the same thing in my Android app. – Wei Wen Sep 05 '17 at 16:40