Skip to content

Commit

Permalink
Update paymentForm.js
Browse files Browse the repository at this point in the history
  • Loading branch information
j4ke-exe committed Apr 3, 2024
1 parent 279268f commit 6db45fd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions static/scripts/paymentForm.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
document.addEventListener('DOMContentLoaded', function () {
const cardNameInput = document.getElementById('card-name');
const cardAddressInput = document.getElementById('card-address');
const cardNumberInput = document.getElementById('card-number');
const cardExpiryInput = document.getElementById('card-expiry');
const cardCVVInput = document.getElementById('card-cvv');
const nameInput = document.getElementById('name');
const addressInput = document.getElementById('address');
const phoneInput = document.getElementById('phone');
const emailInput = document.getElementById('email');

Expand All @@ -14,6 +14,11 @@ document.addEventListener('DOMContentLoaded', function () {
});


cardAddressInput.addEventListener('input', function () {
this.value = this.value.replace(/[^A-Za-z0-9\s.,-]/g, '');
});


cardNumberInput.addEventListener('input', function () {
let value = this.value.replace(/\D/g, '');
value = value.match(/.{1,4}/g)?.join(' ') ?? '';
Expand Down Expand Up @@ -42,13 +47,8 @@ document.addEventListener('DOMContentLoaded', function () {
nameInput.addEventListener('input', function () {
this.value = this.value.replace(/[^A-Za-z\s.-]/g, '');
});


addressInput.addEventListener('input', function () {
this.value = this.value.replace(/[^A-Za-z0-9\s.,-]/g, '');
});




phoneInput.addEventListener('input', function () {
let value = this.value.replace(/\D/g, '');
if (value.length > 10) value = value.slice(0, 10);
Expand Down

0 comments on commit 6db45fd

Please sign in to comment.