All Projects → chebur → CHRTextFieldFormatter

chebur / CHRTextFieldFormatter

Licence: MIT license
Provides UITextField formatting masks. Such as phone number and credit card number formatters.

Programming Languages

objective c
16641 projects - #2 most used programming language
shell
77523 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to CHRTextFieldFormatter

Phonenumberkit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
Stars: ✭ 4,362 (+8288.46%)
Mutual labels:  phone-number, formatting
intl-tel-input-rails
intl-tel-input for the Rails asset pipeline
Stars: ✭ 35 (-32.69%)
Mutual labels:  phone-number, formatting
Edittext Mask
The custom masks for EditText. The solution for input phone numbers, SSN, and so on for Android
Stars: ✭ 413 (+694.23%)
Mutual labels:  phone-number, mask
Intl Tel Input
A JavaScript plugin for entering and validating international telephone numbers
Stars: ✭ 5,963 (+11367.31%)
Mutual labels:  phone-number, formatting
Maskededittext
It allows you to add a mask to EditText
Stars: ✭ 184 (+253.85%)
Mutual labels:  phone-number, mask
international-telephone-input
Integration to Magento 2 a jQuery plugin for entering and validating international telephone numbers.
Stars: ✭ 26 (-50%)
Mutual labels:  phone-number, formatting
Stringformatter
Simple Text Formetter (Credit Card Number, Phone Number, Serial Number etc.) Can be used in all text inputs according to the format pattern. If desired, large minor character restrictions can be made in the format pattern.
Stars: ✭ 231 (+344.23%)
Mutual labels:  phone-number, textfield
PhoneNumberKit
Android Kotlin library to parse and format international phone numbers. Country code picker.
Stars: ✭ 124 (+138.46%)
Mutual labels:  phone-number, mask
xslt-sandbox
My xslt sandbox
Stars: ✭ 37 (-28.85%)
Mutual labels:  formatting
color-pop
🌈 Automatic Color Pop effect on any image inspired by Google Photos
Stars: ✭ 21 (-59.62%)
Mutual labels:  mask
FGRoute
Get your device ip address, router ip or wifi ssid
Stars: ✭ 128 (+146.15%)
Mutual labels:  mask
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (-40.38%)
Mutual labels:  formatting
masked-input
Mask input with simple API and rich customization
Stars: ✭ 44 (-15.38%)
Mutual labels:  mask
naija-phone-number
A fast minimal module to validate Nigerian mobile phone numbers using Regular Expressions.
Stars: ✭ 43 (-17.31%)
Mutual labels:  phone-number
MineDown
A MarkDown inspired markup library for Minecraft chat components
Stars: ✭ 128 (+146.15%)
Mutual labels:  formatting
react-headless-phone-input
Headless phone number input component for React. Because phone numbers are hard.
Stars: ✭ 25 (-51.92%)
Mutual labels:  phone-number
react-native-element-textinput
A react-native TextInput, TagsInput and AutoComplete component easy to customize for both iOS and Android.
Stars: ✭ 28 (-46.15%)
Mutual labels:  textfield
vscode-uncrustify
Code format using uncrustify
Stars: ✭ 62 (+19.23%)
Mutual labels:  formatting
remask
A multi-mask lib
Stars: ✭ 99 (+90.38%)
Mutual labels:  mask
phone-number-geo
离线查询手机号归属地
Stars: ✭ 88 (+69.23%)
Mutual labels:  phone-number

CHRTextFieldFormatter

CHRTextFieldFormatter allows you to apply an input mask to a UITextField instance.

Features

  • Does not mute Copy/Cut/Paste events.
  • Correctly calculates cursor position.
  • Does not require UITextField subclassing.
  • Provides CHRTextMask interface to allow custom text masking algorithm implementation.
  • Subclasses NSFormatter.

Implemented Masks

There are two kind of masks available:

  • CHRPhoneNumberMask to apply cellular phone number mask.
  • CHRCardNumberMask to apply credit card number mask.

Phone Number Mask

Phone number mask can be configured to have non-deletable prefix. For example:

    CHRPhoneNumberMask *mask = [CHRPhoneNumberMask new];
    mask.prefix = @"+7";

Installation

Drag *.h and *.m files to your project.

Usage

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.phoneNumberFormatter = [[CHRTextFieldFormatter alloc] initWithTextField:self.phoneNumberTextField mask:[CHRPhoneNumberMask new]];
    self.cardNumberFormatter = [[CHRTextFieldFormatter alloc] initWithTextField:self.cardNumberTextField mask:[CHRCardNumberMask new]];
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (textField == self.phoneNumberTextField) {
        return [self.phoneNumberFormatter textField:textField shouldChangeCharactersInRange:range replacementString:string];
    } else if (textField == self.cardNumberTextField) {
        return [self.cardNumberFormatter textField:textField shouldChangeCharactersInRange:range replacementString:string];
    } else {
        return YES;
    }
}

Run the example project to see the demo.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].