how to mask first Five digit number on keyup using *
I modified your code to mask first 5 characters. Also this is bullet proof if someone paste a copied number.
https://codepen.io/anon/pen/PLvRWw
// Replace first 5 numbers with astericks
if (displayVal.length < 6){
displayVal = displayVal.replace(/[0-9]/g, '*');
}
else{
displayVal = '*'.repeat(5) + val.slice(5);
}