Skip to main content
Participant
September 10, 2023
Question

Code for displaying "*" after inputing a social security number

  • September 10, 2023
  • 3 replies
  • 1177 views

Is there a code that will change numbers to "*" after inputing a Social Security Number into a text box. Yet if I click in the box I can view what the number is?

This topic has been closed for replies.

3 replies

JR Boulay
Community Expert
Community Expert
September 11, 2023

You're right.

I thought this was its default behaviour, but I checked and it's not.
You need to add two lines of script as in the attached example.

 

On Focus:

event.target.password = false;

 

On Blur:

event.target.password = true;

 

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
September 11, 2023

There is no need for any code, this option is available in the field Properties:

(Note that the data in the field is not saved when the document is saved to disk)

 

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
September 11, 2023

@JR BoulayIf used that then you can't see number when you click in field which is what OP asked.

Yet if I click in the box I can view what the number is?

Nesa Nurani
Community Expert
Community Expert
September 10, 2023

You can use this as 'Custom Format' script:

if(event.value)
event.value = event.value.replace(/./g, '*');
try67
Community Expert
Community Expert
September 10, 2023

Be aware this is absolutely not a safe way to hide the text the user enters, unless they print out the file.

In the digital version of the file it will be trivial to get the actual value from the field. If you want to actually replace the numbers with an asterisk then you can't use the Format event. But in that case what's the point of entering it at all?