# Masking social security

**URL:** <https://forum.wixstudio.com/t/masking-social-security/68327>\
**Category:** Ask the community\
**Tags:** wix-forms, code, question\
**Created:** [February 3, 2025, 2:03pm UTC](https://forum.wixstudio.com/t/masking-social-security/68327 "2025-02-03T14:03:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franklin\_Guanipa](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/franklin_guanipa/32/98017_2.png) [@Franklin\_Guanipa](https://forum.wixstudio.com/u/Franklin_Guanipa)\
**Post date:** [February 3, 2025, 2:03pm UTC](https://forum.wixstudio.com/t/masking-social-security/68327/1 "2025-02-03T14:03:33Z")

</div>

**Question:**  
I need to mask a social security form field but I am getting multiple errors

**Product:**  
Wix velo code

**What are you trying to achieve:**  
I want the social security number to be masked, only show last 4 when is complete and securely saved when submitted for me to access

**What have you already tried:**  
this is my current code  
import wixWindow from ‘wix-window’;  
import wixData from ‘wix-data’; // For potential form submission (optional)  
import wixForms from ‘wix-forms’;

$w.onReady(function () {  
let form1 = $w(“#form1”); // Replace “myForm” with the actual ID of your Wix Form element

// Access the Social Security Number field using its field name  
let socialSecurityNumberField = form1.getFieldValues(“social\_security\_number”);

if (socialSecurityNumberField) {  
socialSecurityNumberField.onChange((event) =\> {  
let inputValue = event.target.value.replace(/\D/g, ‘’); // Remove non-digits  
let maskedValue = “”;

```
  if (inputValue.length > 0) {
    maskedValue = " ***-** -";
  }
  if (inputValue.length > 5) {
    maskedValue += inputValue.substring(5, 9);
  }

  socialSecurityNumberField.value= maskedValue;
});

```

} else {  
console.error(“Social Security Number field not found!”);  
}

// … (Rest of your code)  
});

**Additional information:**  
NA
