I have a form that allows a user to type in a social security number. I want the HTML input to hide the first 5 digits while only showing the last 4 digits.
For example, if the user types 123-45-6789
, then the input will show ***-**-6789
. I am using the Inputmask Plugin to mask the input and force the user to type in the digits in the set format. However, I am puzzled with how to show the first 5 digits as asterisk while making the rest visible.
Here is the mask I am currently using
<input type="text" class="masked-input" data-inputmask="'mask': '999-99-9999'" value="" />
Here is how I activate that input
(function () {
Inputmask().mask(document.querySelectorAll(".masked-input"));
});
How to make input show as asterisk "password" except for the last 4 digits? If it is not possible using this plugin, how can I do it without this plugin or using other plugins?
Closest I could get is the code below: