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

Javascript question-Adobe X Pro

New Here ,
Oct 04, 2018 Oct 04, 2018

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);

TOPICS
Acrobat SDK and JavaScript , Windows
579
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

correct answers 1 Correct answer

Community Expert , Oct 04, 2018 Oct 04, 2018

Change this line:

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

To:

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

Translate
Community Expert ,
Oct 04, 2018 Oct 04, 2018

Use valueAsString instead of value...

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
New Here ,
Oct 04, 2018 Oct 04, 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.

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 ,
Oct 04, 2018 Oct 04, 2018

Change this line:

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

To:

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

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
New Here ,
Oct 04, 2018 Oct 04, 2018
LATEST

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

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