Skip to main content
Known Participant
May 22, 2025
Question

Name and Pin if true auto populate another field with a number

  • May 22, 2025
  • 1 reply
  • 1524 views

I am a novice to javascript and I am using Adobe Pro. I am trying to get a name and pin combination and if true have a different field auito populate a prior approval number of 8 digits. I have tried numerous suggetions from the community but I have not had success. I basically have no code to create this. Thank you for your help.

1 reply

try67
Community Expert
Community Expert
May 22, 2025

You need to provide some more info. By "pin" do you mean password, as in a login? If so, where is the login information stored? In your code? Are you aware that that code can be viewed by anyone who has Acrobat (or other similar tools), and is therefore not secured at all?

Also, what "approval number" do you want to display? A fixed one? A random one? Something else?

Please be more specific.

brantpro1Author
Known Participant
May 22, 2025

Great questions. I am not to worried about overall security. Then pin is a four digit pin. I can store in a excel file or in code, would need to know ho to do excel file. The approval number is a fixed assigned number to each person and needs to be in a text field in the form. Thank you

try67
Community Expert
Community Expert
May 23, 2025

Here is my code. i am getting the error, exception in line 14 of function top_level, script Field:Calculate. Can you help me figure this out. Thank you.

function autoFill() {
var name = this.getField("Name").value;
var pin = this.getField("Pin").value;
if (name === "Yookyung Kim" && pin === "1492") {
this.getField("Approval Number").value = "12481570";
} else if (name === "Madison St.John" && pin === "8107") {
this.getField("Approval Number").value = "12453397";
} else {
app.alert("Invalid Name and PIN combination.");
this.getField("Approval Number").value = "";


You're missing two curly brackets at the end of the code.