Description
Input Mask
is an Android & iOS native library allowing to format user input on the fly.
The library provides you with a text field listener; when attached, it puts separators into the text while user types it in, and gets rid of unwanted symbols, all according to custom predefined pattern.
This allows to reformat whole strings pasted from the clipboard, e.g. turning pasted 8 800 123-45-67
into
8 (800) 123 45 67
.
Each pattern allows to extract valuable symbols from the entered text, returning you the immediate result with the text field listener's callback when the text changes. Such that, you'll be able to extract 1234567
from 8 (800) 123 45 67
or 19991234567
from 1 (999) 123 45 67
with two different patterns.
All separators and valuable symbol placeholders have their own syntax. We call such patterns "masks".
Mask examples:
- International phone numbers:
+1 ([000]) [000] [00] [00]
- Local phone numbers:
([000]) [000]-[00]-[00]
- Names:
[A][-----------------------------------------------------]
- Text:
[A…]
- Dates:
[00]{.}[00]{.}[9900]
- Serial numbers:
[AA]-[00000099]
- IPv4:
[099]{.}[099]{.}[099]{.}[099]
- Visa card numbers:
[0000] [0000] [0000] [0000]
- MM/YY:
[00]{/}[00]
- UK IBAN:
GB[00] [____] [0000] [0000] [0000] [00]
Questions & Issues
Check out our wiki for further reading.
Please also take a closer look at our Known issues section before you incorporate our library into your project.
For your bugreports and feature requests please file new issues as usually.
Should you have any questions, search for closed issues or open new ones at StackOverflow with the input-mask
tag.
We also have a community-driven cookbook of recipes, be sure to check it out, too.
Installation
Gradle
Make sure you've added Kotlin support to your project.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.lndmflngs:input-mask-android:1.0.0'
}
Special thanks
These folks rock:
- Artem Fi5t Kulakov
- Nikita nbarishok Barishok
- Roman yatsinar Iatcyna
- Alexander xanderblinov Blinov
- Vladislav Shipaaaa Shipugin
- Vadim vkotovv Kotov
License
The library is distributed under the MIT LICENSE.