All Projects → Serheo → Phonenumberformatter

Serheo / Phonenumberformatter

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

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Phonenumberformatter

Shsphonecomponent
UITextField and NSFormatter subclasses for formatting phone numbers. Allow different formats for different countries(patterns).
Stars: ✭ 367 (+331.76%)
Mutual labels:  phone, formatter
Google Libphonenumber
The up-to-date and reliable Google's libphonenumber package for node.js.
Stars: ✭ 984 (+1057.65%)
Mutual labels:  phone, formatter
Brazilian Utils
Utils library for specific Brazilian businesses
Stars: ✭ 1,023 (+1103.53%)
Mutual labels:  phone, formatter
Scalafmt
Code formatter for Scala
Stars: ✭ 1,055 (+1141.18%)
Mutual labels:  formatter
Arg.js
🇦🇷 🛠 NPM library. Validation of Argentinian bank account numbers, IDs and phone numbers
Stars: ✭ 52 (-38.82%)
Mutual labels:  phone
Fullstack Phone
A dual-module phone number system with dynamic regional metadata ☎️
Stars: ✭ 76 (-10.59%)
Mutual labels:  phone
Black Playground
ambv/black online demo
Stars: ✭ 83 (-2.35%)
Mutual labels:  formatter
Sqlformat
.NET SQL Parser and Formatter Tool and SSMS Plugin
Stars: ✭ 49 (-42.35%)
Mutual labels:  formatter
Elm Format
elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide
Stars: ✭ 1,240 (+1358.82%)
Mutual labels:  formatter
Align
A general purpose application and library for aligning text.
Stars: ✭ 63 (-25.88%)
Mutual labels:  formatter
Typeset
自动修正中文、英文、代码混合排版中的全半角、空格等问题
Stars: ✭ 63 (-25.88%)
Mutual labels:  formatter
Cn Mobile Location
中国手机号码归属地接口
Stars: ✭ 53 (-37.65%)
Mutual labels:  phone
Vonage Dotnet Sdk
Nexmo REST API client for .NET, ASP.NET, ASP.NET MVC written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 76 (-10.59%)
Mutual labels:  phone
Input Mask Android
User input masking library repo.
Stars: ✭ 1,060 (+1147.06%)
Mutual labels:  formatter
Texttable
Swift package for easily rendering text tables. Inspired by the Python tabulate library.
Stars: ✭ 82 (-3.53%)
Mutual labels:  formatter
Psscriptanalyzer
Download ScriptAnalyzer from PowerShellGallery
Stars: ✭ 1,137 (+1237.65%)
Mutual labels:  formatter
Aspnetcorecsvimportexport
ASP.NET Core CSV import export custom formatters
Stars: ✭ 77 (-9.41%)
Mutual labels:  formatter
Vse Formatdocumentonsave
Visual Studio - Format Document on Save
Stars: ✭ 61 (-28.24%)
Mutual labels:  formatter
Rspec Hue formatter
Bring RSpec integration into your room with Philips Hue
Stars: ✭ 59 (-30.59%)
Mutual labels:  formatter
Parallel Prettier
Concurrent prettier runner
Stars: ✭ 84 (-1.18%)
Mutual labels:  formatter

Phone Number Formatter

Build Swift Carthage compatible

UITextField and NSFormatter subclasses for formatting phone numbers. Allow different formats for different countries(patterns). Caret positioning works excellent. Swift 4.
If you need ObjC support use - https://github.com/Serheo/SHSPhoneComponent/

Installation

Carthage

github "Serheo/PhoneNumberFormatter"

CocoaPods

pod "SwiftPhoneNumberFormatter"

Getting Started

Default Format

textField.config.defaultConfiguration = PhoneFormat(defaultPhoneFormat: "(###) ###-##-##")

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

Image

Prefix Format

You can set prefix on all inputs:

textField.config.defaultConfiguration = PhoneFormat(defaultPhoneFormat: "(###) ###-##-##")
textField.prefix = "+7 "

Multiple Formats

textField.config.defaultConfiguration = PhoneFormat(defaultPhoneFormat: "##########")
textField.prefix = nil
let custom1 = PhoneFormat(phoneFormat: "+# (###) ###-##-##", regexp: "^7[0-689]\\d*$")
textField.config.add(format: custom1)

let custom2 = PhoneFormat(phoneFormat: "+### ###-##-##", regexp: "^380\\d*$")
textField.config.add(format: custom2)

Multiple Formats with prefix

textField.config.defaultConfiguration = PhoneFormat(defaultPhoneFormat: "### ### ###")
textField.prefix = "+7 "

let custom1 = PhoneFormat(phoneFormat: "(###) ###-##-##", regexp: "^1\\d*$")
textField.config.add(format: custom1)

let custom2 = PhoneFormat(phoneFormat: "(###) ###-###", regexp: "^2\\d*$")
textField.config.add(format: custom2)

Listening to changes

To be notified of changes on the textField input add a textDidChangeBlock closure

textField.textDidChangeBlock = { field in
  if let text = field?.text, text != "" {
      print(text)
  } else {
      print("No text")
  }

Attempting to listen to changes through other means will likely fail (e.g., implementing UITextFieldDelegate's textField:shouldChangeCharactersIn:range:).

Requirements

iOS 9+ Swift 4

License

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