September 22, 2012
mask output of the input field
Question by telexper
is there any way to mask the output of the input field once passed to the next page
Enter Card : 123456789011
after the data has been passed onto the next page
when displayed it should look like this
Card info: ********9011
the first 8 digits was converted to asterisk and
the last 4 digits of the card is visible.
Answer by Rhyono
If you’ve already ensured that the card number is a valid length:
card = "123456789011";
output = "********" + card.substring(card.length-4);
is all you’ll need. Output will now be as you wanted, and although Starx’s answer is dynamic: it’s also overkill.