function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mahimmahim 

SSN format in visualforce page

Hi Everyone,

I Have one object in that i have created a Text field. This text field should take the SSN number. When user typing or entering number it should take the SSN format
***-**-1234
last four digits should display. When I am typing the after first 4 digits it should display the - and after again 2 digits again it should display - and last 4 digits should visible to everyone.
From encrypted field I can’t populate – after 4 digits and again after 6 digits. I would like build a visualforce page with Jquery but I don’t know jquery.

Any help is highly appreciated
sam sammsam samm
public static String semiMaskSSN(String ssn){
  String maskedSSN = '';
if(ssn  != null && ssn.length() == 9){
   maskedSSN = '***-**-' + ssn.substring(5, ssn.length()); 
  }
  return maskedSSN;
}