How to you troubleshoot the error "the value entered does not match the format of the field"?

New Here ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

How to you troubleshoot the error "the value entered does not match the format of the field"?  The message is being generated more than 50 times in the file.  You have to click OK on each of the messages before you can do anything else in the file.  When you edit the javascript you get the same error message but may reference another field.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

116

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

Do you use divisions in your calculations?

Likes

Translate

Translate

Report

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 ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

No, just sums.  See example below.  Field1 is a text field with a value of "." or "yes".  Fields 2, 3, and 4 are total fields of numbers.  The *1 is being used to get the formatting needed of the number without decimal places. 

var a=this.getField("field1");

var b=this.getField("field2");

var c=this.getField("field3");

var d=this.getField("field4");

if (a.value=="yes"){event.value=''}

else

event.value=b.value+c.value+d.value*1;

if (event.value==0||event.value=='') {event.value=''};

Likes

Translate

Translate

Report

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
Most Valuable Participant ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

Change this line:

event.value=b.value+c.value+d.value*1;

To:

event.value=Number(b.value)+Number(c.value)+Number(d.value);

Likes

Translate

Translate

Report

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
LEGEND ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

LATEST

One needs to understand how JavaScript handles the types of string and number values and what the "+" operator does. The "+" operator is either the add or concatenate, join strings into one string, depending upon what JavaScript thinks the type of the inputs. If all the values are numbers it will perform addition, but if any of the input values is considered a string by JavaScript then that and following actions will be concatenation.

You can observe what is happening by setting the Format for the field or fields with the error to "None" and observing the result.

A numerical value can have a type of number or string depending upon how JavaScript interprets the input data. One can force a value to either a number or string by using the constrictor of Number or String. It is also possible to use other actions to force a variable or value to be either a string or number. Multiplying by 1 will force a value to be a number before any other operation.

Likes

Translate

Translate

Report

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