Greens
Greens

Reputation: 3067

JQuery SSN Mask

How do I mask SSN in a Textbox and only show the last 4 digits of SSN when I load up a page using JQuery?

Upvotes: 3

Views: 4137

Answers (2)

Kushal Chavan
Kushal Chavan

Reputation: 3

This is how you can mask your SSN Number using JS

.replace(/\D/g, '').replace(/^(\d{3})(\d{1,2})/, '$1-$2').replace(/^(\d{3})-(\d{2})(.+)/, '$1-$2-$3').substring(0, 11)

Upvotes: 0

Gabriel Hurley
Gabriel Hurley

Reputation: 40072

If you're masking it with jQuery you've already got a security hole. You need to mask it server-side otherwise it's being sent unmasked across the network. That's a huge privacy and identity theft problem.

Upvotes: 12

Related Questions