Copy link to clipboard
Copied
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);
Change this line:
populate.value=one.value + '-' + two.value + '-' + three.value;
To:
populate.value=one.valueAsString + '-' + two.valueAsString + '-' + three.valueAsString;
Copy link to clipboard
Copied
Use valueAsString instead of value...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Change this line:
populate.value=one.value + '-' + two.value + '-' + three.value;
To:
populate.value=one.valueAsString + '-' + two.valueAsString + '-' + three.valueAsString;
Copy link to clipboard
Copied
That took care of the problem. I was putting the "AsString" in the wrong place. Thanks for the help.