Input-mask-ios: Get original string

Created on 27 Sep 2017  ·  6Comments  ·  Source: RedMadRobot/input-mask-ios

How to get original string?
For example, i have mask {(123)}-[000] and text field text is "(123)456, i want to get what exactly user enter, is that case - 456.

question

All 6 comments

Hey @beltik
Thanks for your question.

MaskedTextFieldDelegate has a listener with a callback method textField(_:didFillMandatoryCharacters:didExtractValue:), where the «extracted value» is a variable you seek, see the Usage section for the implementation details.

Thanks.
I also want to feature to add any character or digit or symbol to user input.
Currently for do that, i drag library to my object and modified.
Reason is, i needed symbols like ".%@?" etc.

@beltik,

I'm not sure I've understood you right, but there's a feature request about special characters, and the current work is in progress.

P.s. Also, according to your mask format, for {(123)}-[000] you will receive a resulting value like (123)000, with (123) prefix included.

In order to omit it, you should incorporate a format like (123)-[000].

@taflanidi

If i have mask like [-] or [_] i can only enter letters or numbers, but what about symbols like dot? Currently i can't type dot and other symbols in field.

To add that ability i did drag library from pods to project and modify it. There is a method that returns only specific character set depend on enum case, i simply comment it and return YES (because it suite to my needs). But better solution is to add something like ["specific-key"] that allow to edit all symbols.

Let me try to explain again. I need ability to add symbols like "," or ".".
For do that, i copied library to my project, and in class ValueState in func func accepts(character char: Character) -> Bool {
I replaced code with following:
case .AlphaNumeric:
// return CharacterSet.alphanumerics.isMember(character: char)
return true

But, of course i would preffer adding additional case, like case .everyCharacter. And that feature i request for (or maybe there is an simplier way but i did not found it).
Hope i make myself clear.

Implemented in 3.3.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

razalur picture razalur  ·  3Comments

MrJox picture MrJox  ·  11Comments

Robuske picture Robuske  ·  4Comments

osterlind picture osterlind  ·  3Comments

SteynMarnus picture SteynMarnus  ·  11Comments