Usage of this code is to show only the last four digits of an input.
Here I want to replace this "(/.(?=.{4})/g, '*')" '4' with variable 'mask' . Something like that.
x.value = x.value.replace(/.(?=.{+mask+})/g, '*');
Any suggestion plz
function myFunction(mask) {
var x = document.getElementById("cc");
x.value = x.value.replace(/.(?=.{4})/g, '*');
}
<input type="text" id="cc" onkeyup="myFunction(4)" style="text-align:right">