Calm motion: animations on this site only fade, with no movement
CardInput
Card number with groups, brand, and Luhn check
A field for a payment card number. It groups the digits as they print on the card, names the network, and checks the number. Use it with a payment provider that accepts the number from your own form. If the provider gives you hosted fields, use those instead, because the number then never touches your page.
Basic
digits: — · try 4242 4242 4242 4242 or 3782 822463 10005
v-modelholds the digits only (4242424242424242). The box shows the groups: 4-4-4-4, and 4-6-5 for American Express.- Type, paste, or edit in the middle of the number. The component drops other characters, cuts the number to the length of its network, and keeps the caret next to the digit that you typed.
- The network name (
visa,mastercard,amex,discover,jcb,diners,unionpay) shows at the end of the field.brandfires when it changes.cardBrand,formatCardandluhnare exported. - When the number is complete and fails the Luhn check, the field turns invalid after blur and shows "Check the card number". Replace the text with
labels.invalid.:validate="false"turns the check off. - The Luhn check finds typing errors. It does not tell you that the card exists or has funds.
- The field sets
inputmode="numeric"andautocomplete="cc-number", so phones show the number keypad and browsers offer saved cards.
Usage
ts
import { BlessCardInput } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
validate | boolean | true | check the number with the Luhn algorithm once it is complete |
labels | Partial<{ invalid: string; }> | — | |
modelValue | string | "" | the digits only, for example `4242424242424242` |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
brand | [brand: BlessCardBrand] |