Copy link to clipboard
Copied
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).
A very similar question was just answered here: When entering data into text field I get this message - “The value entered does not match the format of the field [CostP…
Copy link to clipboard
Copied
A very similar question was just answered here: When entering data into text field I get this message - “The value entered does not match the format...
Copy link to clipboard
Copied
Thanks for this solution.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You need to solve the division by zero problem, and then you'll be able to use the Number format.
Copy link to clipboard
Copied
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 = "";
}
Copy link to clipboard
Copied
This solution also works. Great! Thanks
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
The solution described above is valid in your case, too. You have to make sure the amount is not zero before dividing by it.
Copy link to clipboard
Copied
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 = "";
}
Copy link to clipboard
Copied
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?