FieldKit provides real-time, text field formatting as users type. It simplifies input formatting and creates a more polished experience for users, while outputting standardized data.
The CardTextField
and AdaptiveCardFormatter
provide formatting for credit card PANs, preventing the input of non-digit characters and automatically breaking into digit groups according to the rules for the entered card type.
“411111111” | “4111 1111 1” (Visa) |
“3725123456” | “3725 123456” (Amex) |
“4111” + backspace | “411” |
The NumberFormatter
provides formatting for all kinds of numbers, percentages, currencies, etc.
The ExpiryDateField
wraps ExpiryDateFormatter
for credit card expiry
dates, preventing the input of nonsense months or non-date characters. It also adds the preceding zero and the slash between the month and year automatically, but treats them as if they are not
there. In order to do this predictably it forces the cursor to remain at the end of the field and prevents any kind of selection.
“4” | “04/” |
“1212” | “12/12” |
“12/” + backspace | “1” |
The SocialSecurityNumberFormatter
provides formatting for US Social Security numbers, preventing the input of non-digit characters and automatically breaking into digit groups like NNN-NN-NNNN
.
“1234” | “123-4” |
“123-45-” + backspace | “123-4” |
The PhoneFormatter
provides formatting for phone numbers, preventing the input of non-digit characters and automatically formatting like (NNN) NNN-NNNN
.
“4155” | “(415) 5” |