Skip to main content
Participant
October 4, 2018
Answered

Javascript question-Adobe X Pro

  • October 4, 2018
  • 2 replies
  • 552 views

I have a form that we enter the social security number in three different fields at the beginning of the form and then combine those into one field for auto insertion into other fields later in the form.The coding listed below works real well except when you enter something like 123 04 5678 it shows 123-4-5678. We need that missing zero to show. I have spent hours looking on the web and have tried things like  "toString in the "this.getfield' line, padding the fields with blanks, and others on this website and nothing works. If anyone has any suggestions on how to get the right output it would be greatly appreciated.

var three = this.getField("Social Security");
//this function that checks if the destination field is blank and if so popluates it.
function collatePreSetFieldsTo(populate){
//always overwrite the value in populate field
//if(populate.value==''||populate.value==null){
var one = this.getField("SSF");
var two = this.getField("SSM");
var three = this.getField("SSL");
populate.value=one.value + '-' + two.value + '-' + three.value;
//}
}

collatePreSetFieldsTo(three);

This topic has been closed for replies.
Correct answer try67

Change this line:

populate.value=one.value + '-' + two.value + '-' + three.value;

To:

populate.value=one.valueAsString + '-' + two.valueAsString + '-' + three.valueAsString;

2 replies

Participant
October 4, 2018

That is the other one I tried but maybe I put it in the wrong place. Can you tell how that coding should look? Thanks.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 4, 2018

Change this line:

populate.value=one.value + '-' + two.value + '-' + three.value;

To:

populate.value=one.valueAsString + '-' + two.valueAsString + '-' + three.valueAsString;

Participant
October 4, 2018

That took care of the problem. I was putting the "AsString" in the wrong place. Thanks for the help.

try67
Community Expert
Community Expert
October 4, 2018

Use valueAsString instead of value...