For eg while i am typing my ssn number my first 5 dight must be masked to *
123456789 => *****6789
Note :on keyup it should check no of digits and mask based on it.
I came through this below example. It mask the entire nine digit.
https://codepen.io/anon/pen/VROrdo
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With