All Projects → Serheo → Shsphonecomponent

Serheo / Shsphonecomponent

Licence: mit
UITextField and NSFormatter subclasses for formatting phone numbers. Allow different formats for different countries(patterns).

Projects that are alternatives of or similar to Shsphonecomponent

Google Libphonenumber
The up-to-date and reliable Google's libphonenumber package for node.js.
Stars: ✭ 984 (+168.12%)
Mutual labels:  phone, formatter
Anyformatkit
Simple text formatting in Swift
Stars: ✭ 296 (-19.35%)
Mutual labels:  formatter, uitextfield
Brazilian Utils
Utils library for specific Brazilian businesses
Stars: ✭ 1,023 (+178.75%)
Mutual labels:  phone, formatter
Crboxinputview
Verify code input view. Support security type for password.短信验证码输入框,支持密文模式
Stars: ✭ 749 (+104.09%)
Mutual labels:  phone, uitextfield
Phonenumberformatter
UITextField subclass for formatting phone numbers. Allow different formats for different countries(patterns).
Stars: ✭ 85 (-76.84%)
Mutual labels:  phone, formatter
Bankcardformat
💳 自动格式化银行卡号的EditText,卡号格式化、归属银行及卡别判断
Stars: ✭ 273 (-25.61%)
Mutual labels:  formatter
Home Automation
Raspberry Pi 3 based home automation with NodeJS and React Native.
Stars: ✭ 3,395 (+825.07%)
Mutual labels:  phone
Soup
☎️ Original open source call flooder using Twilio's API.
Stars: ✭ 267 (-27.25%)
Mutual labels:  phone
currency edittext
Simple currency formatter for Android EditText
Stars: ✭ 64 (-82.56%)
Mutual labels:  formatter
Durafmt
🕗 Better time duration formatting in Go!
Stars: ✭ 362 (-1.36%)
Mutual labels:  formatter
React Native Phone Input
Phone input box for React Native
Stars: ✭ 356 (-3%)
Mutual labels:  phone
Social Media Profiles Regexs
📇 Extract social media profiles and more with regular expressions
Stars: ✭ 324 (-11.72%)
Mutual labels:  phone
Androrat
AndroRAT | Remote Administrator Tool for Android OS Hacking
Stars: ✭ 340 (-7.36%)
Mutual labels:  phone
Datavec
ETL Library for Machine Learning - data pipelines, data munging and wrangling
Stars: ✭ 272 (-25.89%)
Mutual labels:  formatter
Rustfmt
Format Rust code
Stars: ✭ 4,049 (+1003.27%)
Mutual labels:  formatter
Telephone number
Phone number validation for Ruby
Stars: ✭ 262 (-28.61%)
Mutual labels:  phone
Scale
🎏 Unit converter in Swift
Stars: ✭ 324 (-11.72%)
Mutual labels:  formatter
Cht Core
The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
Stars: ✭ 354 (-3.54%)
Mutual labels:  phone
Vonage Node Sdk
Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 323 (-11.99%)
Mutual labels:  phone
Gts
☂️ TypeScript style guide, formatter, and linter.
Stars: ✭ 3,714 (+911.99%)
Mutual labels:  formatter

SHSPhoneComponent

UITextField and NSFormatter subclasses for formatting phone numbers. Allow different formats for different countries(patterns). Caret positioning works excellent.

Swift version is here - https://github.com/Serheo/PhoneNumberFormatter

How To Install

Use any of next methods:

  • use embedded framework /SHSPhoneComponents/SHSPhoneComponent.xcodeproj (iOS 8+)
  • pod 'SHSPhoneComponent'
  • copy /SHSPhoneComponents/Library folder to your project.

And import "SHSPhoneLibrary.h" on your Controller.

Example Usage

If you need complete example please see 'Example_iOS7+' or 'Example_iOS8+embedded' folders.

Default Format

[self.phoneField.formatter setDefaultOutputPattern:@"+# (###) ###-##-##"];

shspc example 1

All input strings will be parsed in that way. Example: +7 (920) 123-45-67

Prefix Format

You can set prefix on all inputs:

[self.phoneField.formatter setDefaultOutputPattern:@"(###) ###-##-##"];
self.phoneField.formatter.prefix = @"+7 ";

shspc example 1

Multiple Formats

[self.phoneField.formatter setDefaultOutputPattern:@"##########" imagePath:nil];
[self.phoneField.formatter addOutputPattern:@"+# (###) ###-##-##" forRegExp:@"^7[0-689]\\d*$" imagePath:@"flagRU"];
[self.phoneField.formatter addOutputPattern:@"+### (##) ###-###" forRegExp:@"^374\\d*$" imagePath:@"flagAM"];

shspc example 2

Multiple Formats with prefix

[self.phoneField.formatter setDefaultOutputPattern:@"### ### ###"];
self.phoneField.formatter.prefix = @"+7 ";
[self.phoneField.formatter addOutputPattern:@"(###) ###-##-##" forRegExp:@"^1\\d*$" imagePath:@"SHSPhoneImage.bundle/flag_ru"];
[self.phoneField.formatter addOutputPattern:@"(###) ###-###" forRegExp:@"^2\\d*$" imagePath:@"SHSPhoneImage.bundle/flag_ua"];

Specific Formats

If you want to format some numbers in specific way just do

[self.phoneField.formatter addOutputPattern:@"+# (###) ###-##-##" forRegExp:@"^7[0-689]\\d*$" imagePath:@"flagRU"];
[self.phoneField.formatter addOutputPattern:@"+### (##) ###-###" forRegExp:@"^374\\d*$" imagePath:@"flagAM"];

Formatting

If you need only formatting function you can use SHSPhoneNumberFormatter class. For additional class info see http://serheo.github.io/SHSPhoneComponent/

Issues and Solutions

if you are using any predictions/suggestion in the textfield, set hasPredictiveInput flag to YES.

Requirements

ARC Enabled. iOS 7+

License

SHSPhoneComponent is available under the MIT license. See the LICENSE file for more info.

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].