(number: string)
| 66 | * Format the card number in groups of 4 digits (i.e. 1234 5678 9012 3456). |
| 67 | */ |
| 68 | export const formatCardNumber = (number: string) => { |
| 69 | // Remove non-numeric characters |
| 70 | const cleaned = number.replace(/\D/g, ""); |
| 71 | |
| 72 | // Format the card number in groups of 4 digits |
| 73 | const match = cleaned.match(/\d{1,4}/g); |
| 74 | |
| 75 | if (match) { |
| 76 | return match.join(" "); |
| 77 | } |
| 78 | |
| 79 | return cleaned; |
| 80 | }; |
| 81 | |
| 82 | interface PaymentInputProps extends InputProps {} |
| 83 |