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

Value entered doesn't match the format

Participant ,
Oct 19, 2018 Oct 19, 2018

Copy link to clipboard

Copied

Good Afternoon,

First of all, when I've posted questions on coding JAVASCRIPT people have been amazing as I learn (I'm a novice).  I appreciate any and all feedback.  I have a form that I've been working on and so close to being finished with it.  I keep getting an error "the value entered doesn't match the format of the field".  I've tried but cannot not figure out how to resolve this issue.  The scenario involves a % issue.  I have 3 separate lines that have a % as a result for answer.  The results are considered:  Step 1 ("F7"), Step 2 ("F10") and Step 3 ("F13").  If Step 1 has a result that a percentage will appear.  If step 1 is not used then the answer will appear as 0%.  Same goes for Step 2 and Step 3.  Step 4 ("F14") and this is Step 1 + Step 2 + Step 3.  So, if the result was 1000% then the result would be 3000%.  Step 5 ("F15") is Step 4 / the number of steps is used.  So, if Step 1 is the only the divisor is 1, If Step 1 and Step 2 are used then the divisor is 2.  and If Step 1, Step 2 and Step 3 are used then the divisor is 3.  If no steps are used then the divisor is 0.  The other issue is if the percentage is greater than 100% then the result is 100%.  If if is less than 100% then the result is the average or 0.  Here is the code I've written so far which gives me a result but errors out as with the value entered doesn't match the format of the field.  F1000 will give a value of 1 if step 1 is used, F1001 will give a value of 1 if step 2 is used and F1002 will give a value of 1 if Step 3 is used.  F14 is the percentage values added up for Step 1, Step 2 and Step 3. 

var theField = this.getField("F1000");

var theValue = theField.value;

var theField2 = this.getField("F1001");

var theValue2 = theField2.value;

var theField3 = this.getField("F1002");

var theValue3 = theField3.value;

var theField4 = this.getField("F14");

var theValue4 = theField4.value;

if (theValue+theValue2+theValue3  < .000001) {

    this.getField("F15").value= theValue4 / (theValue + theValue2 + theValue3);

}

else {

     this.getField("F15").value=1;  

}

Any help would be greatly appreciated!

Sincerely,

Steve

TOPICS
Acrobat SDK and JavaScript , Windows

Views

343

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

correct answers 1 Correct answer

LEGEND , Oct 20, 2018 Oct 20, 2018

What happens when you enter numbers to the input fields?

I would first get the calculation working and then set the format as needed.

If the calculation script has been placed in the custom calculation for field "F15" you should be using "event.value" for changing the value of field and not "this.getField("F15").value".

You also might want to open the Acrobat JavaScript console to see if there are any run time errors.

When there is no input and all values are null or zero, the result should be 1 sin

...

Votes

Translate

Translate
LEGEND ,
Oct 19, 2018 Oct 19, 2018

Copy link to clipboard

Copied

Change the format of the field to "None" and observe the result.

In JavaScript the "+" operator can be either the addition operator or the concatenation operator depending upon what JavaScript assumes the values being operated on are numbers or strings. One should be aware that a number character(s) can be a number or a string. One may need to force a variable value to a number using the Number constrictor or some other operation.

Empty fields have a "null" value and are treated as a zero value. Division by zero in JavaScript can result in a number of possible results like "NaN" (Not a Number), Infinity, - Infinity, or a result expressed in scientific notation. All of these values do not match the requirement for the "Number" format which only accepts floating point  or integer values.

You may need to display the values being processed by using the "console.print" method.

Votes

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
Participant ,
Oct 19, 2018 Oct 19, 2018

Copy link to clipboard

Copied

i guess the issue is I need a percent to be the result.  So, if the answer is zero then the answer needs to reflect 0.000%.  When I put in none then it did return a number but not a percentage

Votes

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

Copy link to clipboard

Copied

LATEST

What happens when you enter numbers to the input fields?

I would first get the calculation working and then set the format as needed.

If the calculation script has been placed in the custom calculation for field "F15" you should be using "event.value" for changing the value of field and not "this.getField("F15").value".

You also might want to open the Acrobat JavaScript console to see if there are any run time errors.

When there is no input and all values are null or zero, the result should be 1 since the total of the fields that make up the divisor is zero.

Votes

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