Replace whitespace within input fields: wepay-credit-card.js

This commit is contained in:
Benjamin Beganović 2021-07-14 13:05:29 +02:00
parent 78d2e8f932
commit 25fd6b2346

View File

@ -33,25 +33,25 @@ class WePayCreditCard {
this.errors.hidden = false; this.errors.hidden = false;
return; return;
} else if (this.myCard.CardJs('cardNumber') === "") { } else if (this.myCard.CardJs('cardNumber').replace(/[^\d]/g, '') === "") {
document.getElementById('card_number').focus(); document.getElementById('card_number').focus();
this.errors.textContent = "Card number required."; this.errors.textContent = "Card number required.";
this.errors.hidden = false; this.errors.hidden = false;
return; return;
} else if (this.myCard.CardJs('cvc') === "") { } else if (this.myCard.CardJs('cvc').replace(/[^\d]/g, '') === "") {
document.getElementById('cvv').focus(); document.getElementById('cvv').focus();
this.errors.textContent = "CVV number required."; this.errors.textContent = "CVV number required.";
this.errors.hidden = false; this.errors.hidden = false;
return; return;
} else if (this.myCard.CardJs('expiryMonth') === "") { } else if (this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, '') === "") {
// document.getElementById('expiry_month').focus(); // document.getElementById('expiry_month').focus();
this.errors.textContent = "Expiry Month number required."; this.errors.textContent = "Expiry Month number required.";
this.errors.hidden = false; this.errors.hidden = false;
return; return;
} else if (this.myCard.CardJs('expiryYear') === "") { } else if (this.myCard.CardJs('expiryYear').replace(/[^\d]/g, '') === "") {
// document.getElementById('expiry_year').focus(); // document.getElementById('expiry_year').focus();
this.errors.textContent = "Expiry Year number required."; this.errors.textContent = "Expiry Year number required.";
this.errors.hidden = false; this.errors.hidden = false;
@ -77,10 +77,10 @@ class WePayCreditCard {
client_id: document.querySelector('meta[name=wepay-client-id]').content, client_id: document.querySelector('meta[name=wepay-client-id]').content,
user_name: document.getElementById('cardholder_name').value, user_name: document.getElementById('cardholder_name').value,
email: document.querySelector('meta[name=contact-email]').content, email: document.querySelector('meta[name=contact-email]').content,
cc_number: this.myCard.CardJs('cardNumber'), cc_number: this.myCard.CardJs('cardNumber').replace(/[^\d]/g, ''),
cvv: this.myCard.CardJs('cvc'), cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''),
expiration_month: this.myCard.CardJs('expiryMonth'), expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''),
expiration_year: this.myCard.CardJs('expiryYear'), expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''),
address: { address: {
postal_code: document.querySelector(['meta[name=client-postal-code']).content, postal_code: document.querySelector(['meta[name=client-postal-code']).content,
} }
@ -116,10 +116,10 @@ class WePayCreditCard {
client_id: document.querySelector('meta[name=wepay-client-id]').content, client_id: document.querySelector('meta[name=wepay-client-id]').content,
user_name: document.getElementById('cardholder_name').value, user_name: document.getElementById('cardholder_name').value,
email: document.querySelector('meta[name=contact-email]').content, email: document.querySelector('meta[name=contact-email]').content,
cc_number: this.myCard.CardJs('cardNumber'), cc_number: this.myCard.CardJs('cardNumber').replace(/[^\d]/g, ''),
cvv: this.myCard.CardJs('cvc'), cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''),
expiration_month: this.myCard.CardJs('expiryMonth'), expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''),
expiration_year: this.myCard.CardJs('expiryYear'), expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''),
address: { address: {
postal_code: document.querySelector(['meta[name=client-postal-code']).content, postal_code: document.querySelector(['meta[name=client-postal-code']).content,
} }