Credit card form
Card number, expiry and CVV together. Entering an Amex switches the CVV to 4 digits.
Built-in validation: Luhn and expiry checks
The card number is checked for its network's length and the Luhn checksum, the expiry for invalid and past months. The CVV switches between 3 and 4 digits with the card type.
Preview
Form value: -
Display: -
Form value: -
Display: -
Form value: -
Display: -
Details
- The CVV links to the card with from: "card". The link is explicit; the schema is not scanned.
- An Amex card (34, 37) is grouped 4-6-5 and its CVV has 4 digits. If the card turns into a Visa, the CVV is trimmed to 3 digits on screen and in the form.
- The card is checked with Luhn; the expiry rejects past months.
Card networks
The network comes from the leading digits; the pattern, length and CVV digits follow it.
| Network | Starts with | Length | Grouping | CVV | getCardType |
|---|---|---|---|---|---|
| Visa | 4 | 16 | 4-4-4-4 | 3 | "visa" |
| Mastercard | 51–55, 2221–2720 | 16 | 4-4-4-4 | 3 | "mastercard" |
| American Express | 34, 37 | 15 | 4-6-5 | 4 | "amex" |
| Troy | 9792 | 16 | 4-4-4-4 | 3 | "troy" |
| Other | — | 16 | 4-4-4-4 | 3 | "unknown" |
For the hook API see useViraMask(); for your own pattern see custom mask.