Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

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

New Here ,
Sep 09, 2023 Sep 09, 2023

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?

TOPICS
How to , JavaScript , PDF
856
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2023 Sep 09, 2023

You can use this as 'Custom Format' script:

if(event.value)
event.value = event.value.replace(/./g, '*');
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 10, 2023 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2023 Sep 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)

 

Capture_2309111010.pngexpand image


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 11, 2023 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2023 Sep 11, 2023
LATEST

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 Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines