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

How to resolve "“The value entered does not match the format of the field [x]”?

Contributor ,
Jul 20, 2018 Jul 20, 2018

I have a PDF form with several computed fields:

Field A (How many people?)

-          Input field

-          Format : Numeric (whole number)

Field B (How many days?)

-          Input field

-          Format: Numeric (1 decimal place)

Field C (Total Meal Money)

-          Computed (Field A*Field B*30)

-          Format: $ with 2 decimal places

Field D (Meal / Person)

-          Computed (Field C/Field A)

-          Format: $ with 2 decimal places

Field E (Fuel Money)

-          Input field

-          Format: $ with 2 decimal places

Field F (Emergency Money)

-          Input field

-          Format: $ with 2 decimal places

Field G (Total Cash Requested)

-          Computed (Field C+Field E+Field F)

-          Format: $ with 2 decimal places

I also have created a Reset Form button that runs the following JAVA script:

if(4==app.alert("This action will clear all input fields in this form.\nDo you want to continue?",1,2))this.resetForm()

My issue is that I am getting a Warning which says…

“The value entered does not match the format of the field

a)      each time I click the Reset Form button

b)      when Field A is zero (0) and try to change the value of Field B, Field E or Field F

I noticed that this warning happened when the value of Field A is zero (0).

TOPICS
Create PDFs
37.3K
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
Community Expert ,
Jul 21, 2018 Jul 21, 2018
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 ,
Jul 21, 2018 Jul 21, 2018
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
Contributor ,
Jul 21, 2018 Jul 21, 2018

Thanks for this solution.

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
LEGEND ,
Jul 21, 2018 Jul 21, 2018

To see the actual value of the field without any formatting, set the "Format" to "None". An empty string .,like a blank field, is considered a null value and a null value within a numeric calculation is treated as zero, 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
Contributor ,
Jul 21, 2018 Jul 21, 2018

Following your suggestion, the computed field is showing the text "NaN" and second, I would like to see the field as numeric with two decimal places.

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 ,
Jul 22, 2018 Jul 22, 2018

You need to solve the division by zero problem, and then you'll be able to use the Number format.

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
LEGEND ,
Jul 22, 2018 Jul 22, 2018

For the computation of Filed D you can only perform the calculation when Field A is not zero. You will have to use the Custom JavaScript calculation option.

var nPeople = this.getField("Field A").value;

if(nPeople != 0) {

event.value = this.getField("Field C").value / nPeople;

} else {

event.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
Contributor ,
Jul 22, 2018 Jul 22, 2018

This solution also works. Great! 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
New Here ,
Jul 10, 2020 Jul 10, 2020

I am having the same issue.  I am trying to find use cost divided by amount (example- 10oz at $15.99- need cost per ounce) but if it is a product not being used it is 0 or empty field.  How do I get that to compute?  So confused...if it was excel I would get it LOL

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 ,
Jul 10, 2020 Jul 10, 2020

The solution described above is valid in your case, too. You have to make sure the amount is not zero before dividing by it.

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 ,
Nov 08, 2024 Nov 08, 2024

This worked but what if it is 2 fields I want to make sure arent blank?

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 ,
Nov 08, 2024 Nov 08, 2024
LATEST

Then use something like this:

 

var a = this.getField("Field A").valueAsString;
var b = this.getField("Field B").valueAsString;

if(a=="" || b=="") {
	event.value = "";
} else {
	event.value = Number(a) / Number(b);
}
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 ,
Aug 25, 2020 Aug 25, 2020

These solutions work for me to remove the error from the divide by "0", but now the calculation is not calculating properly. 

Below is my current calculation script. ultimately it is adding "1" to the final output and not completing the "*100" step.

For example, if the current rate is 25 and the new rate is 26, it was calculating the percentage increase correctly at 4.00%, then I added the suggested solution in italics, and the new result of the calculation is now 1.04. How do I get it to go back to calculating correctly to 4.00% without the divide by 0 error?

 

event.value = ( this.getField("New Hourly Rate").value - this.getField("Current Hourly Rate").value ) / ( this.getField("Current Hourly Rate").value ) * 100;
var nPeople = this.getField("Current Hourly Rate").value;
if(nPeople != 0) {
event.value = this.getField("New Hourly Rate").value / nPeople;
} else {
event.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
Community Expert ,
Aug 25, 2020 Aug 25, 2020

The first part of your code doesn't make sense. It gets completely overwritten by the second part, no matter what the values are. Why are you using it?

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