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

Show Zero Value instead of "The value entered does not match the format of the field [ ]"

New Here ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

I am using simplified filed notation to perform subtractions on a budget form.

They all work great and have no trouble displaying a zero value when its a simple subtraction (value1-value2).

However on my last field I want to take the total income and subtract everything I have spent (about 40 fields) and get a zero balance.

When i try to do this i get this warning "The value entered does not match the format of the field [ ]"

The calculation works fine and displays the correct value for anything above ".01" and will display negative numbers ".01" and below as well (if i go over budget), it just cannot display a zero, which is my goal for that to equal zero every month.

I tried looking though the forms and haven't found an answer that works yet for my situation.


Happy to post the form here as well, just not sure how to do it.

Thanks in advance,

TOPICS
Acrobat SDK and JavaScript

Views

565

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

correct answers 1 Correct answer

LEGEND , Apr 04, 2016 Apr 04, 2016

The custom calculation script can be something like the following:

// Get the Income field value, as a number

var v1 = +getField("Income").value;

// Set up an array of field names

var aFieldsToSubtract = [

"ThithesB",

"CharityB",

"EFundB",

"MortgageB",

"HomeItemsB",

"HomeRepairsB",

"ElecticB",

"GasB",

"WaterB",

"SewerB",

"TrashB",

"PhoneB",

"InternetB",

"AutoInsB",

"UmbrellaB",

"IdentityB",

"CosmeticsB",

"ToiletriesB",

"PocketEBB",

"PocketCBB",

"GiftsB",

"HouseSuppliesB",

"PersonalOtherB",

"PersonalOther2B",

"GroceriesB",

"R

...

Likes

Translate

Translate
Community Expert ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

This means there's something wrong with the calculation. The first step would be to remove the Number format option from the Total field. That should take care of the error "invalid format" message. Then you should check the JS console (Ctrl+J) for any errors or warnings. If there are any, post them here.

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

The problem is usually due to the result of the subtraction being something very close to zero. See this previous discussion for more info: Value Entered does not match format of field

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

I would try setting the "Format" to "None" and then look at the result. Do you see any spaces between the digits displayed?

Now clear the form and start entering the individual values and observe the results.

Do you have calculations that require division?

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

Thank you all for your advice.

try67 - removed formatting and the resulting balance is 0.010000000001099352 where it should simply be .01

george -  that didnt work for me, plus i don't want a band aid fix, i want to fix the real problem. if its displaying 0.010000000001099352 when it should be simply .01, then there is an issue and i want to fix it.

gkaiseril - removed formatting and the resulting balance is 0.010000000001099352 where it should simply be .01. there is division happening on the form, but not in the calculation in question

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

Sorry hit enter to early.

I meant to say:

Thank you all for your advice.

try67 - removed formatting and the resulting balance is 0.010000000001099352 where it should simply be .01, i dont see any errors when i look at the debugger

george -  that didnt work for me, plus i don't want a band aid fix, i want to fix the real problem. if its displaying 0.010000000001099352 when it should be simply .01, then there is an issue and i want to fix it.

gkaiseril - removed formatting and the resulting balance is 0.010000000001099352 where it should simply be .01. there is division happening on the form, but not in the calculation in question.

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

gkaiseril - to your point about clearing the form and seeing what happens i did and here are the results.

result 1 - i entered whole number of 100 in every field. When i got to have 3 remaining fields (any three - not necessarily the last or first 3 i tried 5 or 6 different set of 3 all with the same result) when i entered 100 in the 3rd to last field the remaining line when from a nice whole number of "xxx.xx" to "xxx.xxxxxxxxxxxxx"

However my current form that i am using (and having issues on) has multiple fields that are empty, so this last 3 thing should be the cause of it.

so i then tried entering numbers with decimals in all columns ( a more realistic use of the form.

Result 2 - after entering just 4 fields with the number "100.01" i got a balance of "xxx.xxxxxxxxxxxxx" instead of simply "xxx.xx" again doesn't matter which 4 just once the 4th one is entered it returns the skewed result.

thoughts or ideas? How can i post the form for you to look at?

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

One could round the values before performing any calculation. This will remove the error caused by the conversion of the input number to the IEEE 16 bit floating point value. It should be noted that converting decimal fractions values to binary fractions results in irrational binary number and the small extra values cause an error.

As George pointed out in his post you can use the "util.printf()" to round the number to the exact value needed for the 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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

Thanks gkaiseril,

I read George's post before initially responding and i couldn't figure out how to get util.printf() to work. In The linked post, it looks like it was using a custom calculation script. In my form I am using simplified field notation's like:

simple: GroceriesB-GroceriesS

complex: Income-ThithesB-CharityB-EFundB-MortgageB-HomeItemsB-HomeRepairsB-ElecticB-GasB-WaterB-SewerB-TrashB-PhoneB-InternetB-AutoInsB-UmbrellaB-IdentityB-CosmeticsB-ToiletriesB-PocketEBB-PocketCBB-GiftsB-HouseSuppliesB-PersonalOtherB-PersonalOther2B-GroceriesB-RestaurantsB-ClothingB-CarGasB-CarRepairsB-CarOtherB-MedicalBillsB-MedicalOtherB-EntertainmentB-VacationB-DebtCarB-DebtStudentLoan1B-DebtStudentLoan2B-DebtStudentLoan3B-DebtCreditB-DebtOther1B-DebtOther2B

is there anyway to adapt util.printf() to work with my simplified field notation or do i need to redo my entire form using custom calculation script?

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

The custom calculation script can be something like the following:

// Get the Income field value, as a number

var v1 = +getField("Income").value;

// Set up an array of field names

var aFieldsToSubtract = [

"ThithesB",

"CharityB",

"EFundB",

"MortgageB",

"HomeItemsB",

"HomeRepairsB",

"ElecticB",

"GasB",

"WaterB",

"SewerB",

"TrashB",

"PhoneB",

"InternetB",

"AutoInsB",

"UmbrellaB",

"IdentityB",

"CosmeticsB",

"ToiletriesB",

"PocketEBB",

"PocketCBB",

"GiftsB",

"HouseSuppliesB",

"PersonalOtherB",

"PersonalOther2B",

"GroceriesB",

"RestaurantsB",

"ClothingB",

"CarGasB",

"CarRepairsB",

"CarOtherB",

"MedicalBillsB",

"MedicalOtherB",

"EntertainmentB",

"VacationB",

"DebtCarB",

"DebtStudentLoan1B",

"DebtStudentLoan2B",

"DebtStudentLoan3B",

"DebtCreditB",

"DebtOther1B",

"DebtOther2B"

];

// Subtract the field values

for (var i = 0; i < aFieldsToSubtract.length, i += 1) {

    v1 -= +getField(aFieldsToSubtract).value;

}

// Set this field value by rounding the result to the nearest hundredth

event.value = util.printf("%.2f", v1);

Don't think of this as a band-aid, think of it as the correct way to perform the calculation, because it is. Note that "Thithes" may be a misspelling.

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 ,
Apr 04, 2016 Apr 04, 2016

Copy link to clipboard

Copied

George,

Thank you for you help and for taking the time to customize the code for me. I really appreciate that and I am sorry for originally dismissing your answer as incorrect.

Many Thanks,

-Erik

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Hi,

 

I seem to be having the same issue, my form wont balance to 0, if i make it 0.1 it will show i'm over or under but wont actually balance to Zero.

 

The figures are correct, im just unsure how to fix this issue, can anyone help??

 

I have four filds im calcualting using the simplified calculation.

CLOSINGFLOAT+EXPENSES-CASHSALES-STARTINGFLOAT.

STARTING FLOAT = $233.10

CASH SALES= $0.00

EXPENSES= 52.70

CLOSING FLOAT= $180.40

 

So it should balance, if i put 52.69 in expenses it shows -$0.01

If i put in $52.71 in expenses it shows $0.01 over

I'm happy to share the form also.

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
Community Expert ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

LATEST

This is the result of a floating point error. To fix it you would need to use a script to round the values to 2 decimals, for example.

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