Highlighted

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

New Here ,
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,

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

323

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

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

New Here ,
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,

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

324

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
Apr 04, 2016 0
Most Valuable Participant ,
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
Reply
Loading...
Apr 04, 2016 0
Adobe Community Professional ,
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
Reply
Loading...
Apr 04, 2016 0
Adobe Community Professional ,
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
Reply
Loading...
Apr 04, 2016 0
New Here ,
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
Reply
Loading...
Apr 04, 2016 0
New Here ,
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
Reply
Loading...
Apr 04, 2016 0