Copy link to clipboard
Copied
Hello, this may not be possible and if it is... I hope my question makes sense. Please be patient with me as I am still a beginner when it relates to custom script on Adobe DC. I am looking to put a field (let's say it is a field for a social security number). When the user inputs the social security number, it will mask it (to only show the last 4 numbers once entered). When the form is emailed the ssn will show masked. When the recipient receives the email, the recipient can access the full social security number (if they needed to access it). That's all Im trying to do and I hope this makes sense? Thank you in advance for your time and help!
NOTE - there is no such program as Adobe DC, moving to Acrobat
You need to ask program questions in the forum for the program you are using
To ask in the forum for your program please start at https://community.adobe.com/
Moving from Using the Community (which is about the forums) to the correct forum... Mod
Copy link to clipboard
Copied
You can use this code as the custom validation script of the "SSN" field:
this.getField("SSN Reveal").value = "";
if (event.value) {
if (/^\d{3}-\d{2}-\d{4}$/.test(event.value)) {
this.getField("SSN Reveal").value = event.value;
var ssnParts = event.value.split("-");
event.value = "XXX-XX-"+ssnParts[2];
} else {
app.alert("Invalid value.");
event.rc = false;
}
}
Copy link to clipboard
Copied
"Masking" a value in a PDF is purely cosmetic. If you don't want sensitive information to be extracted from the file either don't enter it in the first place, or don't use a PDF file for this purpose, but a more secure way of transferring data.
Copy link to clipboard
Copied
Is there a way to do it even for cosmetic purposes? Thank you for the prompt reply!
Copy link to clipboard
Copied
I found this but it didnt work or I didnt place it in the correct field.
// ssnformmasked::exit - (JavaScript, client)
if (ssnform.rawValue != null) {
var ssn = ssnformmasked.rawValue;
var regExp = /^(\d{9}|\d{3}-\d{2}-\d{4})$/;
if (regExp.test(ssn)) {
regExp = /^\d{9}/;
if (regExp.test(ssn)) {
this.rawValue = "***-**-" + ssn.substring(5,9);
ssnform.rawValue = ssn;
}
else {
this.rawValue = "***-**-" + ssn.substring(7,11);
ssn = ssn.substring(0,3) + ssn.substring(4,6) + ssn.substring(7,11);
ssnform.rawValue = ssn;
}
}
else {
xfa.host.messageBox("SSN must be in the form 123-45-6789 or 123456789.","SSN Error",0,0);
xfa.host.setFocus("ssnformmasked");
}
}
Copy link to clipboard
Copied
This code was written for an LCD form. It will not work in a regular PDF file.
So how should it work, exactly? What should trigger showing the full SSN, as opposed to masking part of it?
Copy link to clipboard
Copied
Hello and my apologies for the delay. You'd enter the # (123-45-6789) and it would automatically show (XXX-XX-6789) to the individual entering the information. Let's call the text field "SSN" and then another hidden field (accessible only by the recipient receiving the data) would get the full number. Let's call that field "SSN Reveal". I hope this makes sense? Oh and any forms would be sent through a secure server / message. I was able to confirm that. Thank you for your valuable time!
Copy link to clipboard
Copied
You can use this code as the custom validation script of the "SSN" field:
this.getField("SSN Reveal").value = "";
if (event.value) {
if (/^\d{3}-\d{2}-\d{4}$/.test(event.value)) {
this.getField("SSN Reveal").value = event.value;
var ssnParts = event.value.split("-");
event.value = "XXX-XX-"+ssnParts[2];
} else {
app.alert("Invalid value.");
event.rc = false;
}
}
Copy link to clipboard
Copied
You are my HERO!!! This is PERFECTION! That is EXACTLY what I needed. Thank you so very much!!!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This script won't work in an Adobe Sign form.
Copy link to clipboard
Copied
If it's an SSN it shouldn't be in an email - even if cosmetically masked. You may have unlimited legal liabilities. You need to use a secure web server (https submit) with script written by a specialist.