Skip to content

Commit

Permalink
Card holder name restriction (#1975)
Browse files Browse the repository at this point in the history
* restrict input to letters and spaces

* allow hyphens

---------

Co-authored-by: Katina Anachkova <[email protected]>
  • Loading branch information
katina-anachkova and Katina Anachkova authored Nov 20, 2024
1 parent 92721a7 commit 4e2b1cb
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export default function PaymentDetailsStripeForm({
id="billingName"
variant="outlined"
placeholder={t('donation-flow:step.payment-method.field.card-data.name-label')}
onInput={(e) => {
const input = e.target as HTMLInputElement
input.value = input.value
.replace(/[^a-zA-Z\s-]/g, '')
.replace(/[-\s]{2,}/g, (match) => match[0])
}}
/>
</Box>
<PaymentElement
Expand Down

0 comments on commit 4e2b1cb

Please sign in to comment.