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

When entering data into text field I get this message - “The value entered does not match the format of the field [CostPerAnnualSales]”(

New Here ,
Jul 20, 2018 Jul 20, 2018

I have a very simple PDF form for our reps to fill out, it consists of text fields and a few fields with numbers. Two of the number fields are calculated in a separate number field with this custom calculation for a percentage outcome:

event.value = (this.getField("TotalDispenserCost").value/ this.getField("ExpectedAnnualSales").value)

It calculates correctly, but when I enter text into the text fields or I trigger the Clear Form, Print Form or Email Form buttons before I enter data into the “TotalDispenserCost” and the “ExpectedAnnualSales” fields I get the following message “The value entered does not match the format of the field [CostPerAnnualSales]”(this is the field that calculates the percentage). BUT I noticed if I enter the numbers into the “TotalDispenserCost” and the “ExpectedAnnualSales” fields first and then enter data in the text fields the message does not appear.

I can’t seem to find this same type of problem on any of the forums that I’ve visited for help. Hope there is a very simple solution to this issue.

TOPICS
PDF forms
14.8K
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
1 ACCEPTED SOLUTION
LEGEND ,
Jul 20, 2018 Jul 20, 2018

You're doing a division, and when you do that when the ExpectedAnnualSales field is blank (or zero), you're dividing by zero, which will result in something that can't be displayed in a field that's set up with a numeric format. The fix is to check to see if the denominator evaluates to zero, and if so, set the calculated value to something like blank. For example:

var numerator = +getField("TotalDispenserCost").value;

var denominator = +getField("ExpectedAnnualSales").value;

if (denominator !== 0) {

     event.value = numerator / denominator;

} else {

    event.value = "";

}

View solution in original post

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 ,
Jan 11, 2021 Jan 11, 2021

I really dont underestand, sorry

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 ,
Jan 11, 2021 Jan 11, 2021

When v3 is 0 the result of v1/v2*v3 is also 0.

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