Skip to content

Unable to limit card number to 16 chars #75

@hcbelias

Description

@hcbelias

I'm trying to find a way to limit credit cards to 16 numbers.

Tried to use the valid card brands like this:

validCardBrands={[ { type: "visa", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "visaelectron", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4], }, { type: "maestro", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "mastercard", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "amex", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "discover", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "dankort", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "dinersclub", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "jcb", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "unionpay", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "forbrugsforeningen", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4], }, { type: "elo", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, { type: "hipercard", pattern: /(\d{1,4}){4}/, format: /(\d{1,4}){4}/g, length: [16], cvvLength: [3, 4] }, ]}

But still allows to type 19 numbers.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions