Answer the question
In order to leave comments, you need to log in
How to substitute * in the middle of the card number?
I want to write a credit card number mask, send it to the server with asterisks too. The problem is that val doesn't change
<input name="paymentCard" class="form-control" type="number" placeholder="**** **** **** ****" id="paymentCard">
function paymentCard() {
if ($('#paymentCard').val() === "") {
return '<?= lang("not_completed")?>';
} else {
const str = $('#paymentCard').val();
const regex = /(?<=\d{4})\d(?=\d{4})/gm;
const subst = `*`;
return str.replace(regex, subst);
}
}
$('#paymentCard').on('keyup', function () {
paymentCard()
});
тут поклацать
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question