Skip to main content
Participant
January 29, 2024
Question

Javascript errors in fillable form with calculations

  • January 29, 2024
  • 2 replies
  • 989 views

I've created a fillable form in Adobe Pro. In it, there are several calculations. All work correctly when I enter sample data. However, when I reset the entire form so I can send to a customer, I start getting "Warning: JavaScript Window -" errors stating "The value does not match the format of the field [list the field]. That warning will come up on all fields with a calculation. The error will only resolve after I enter sample data again. I've set the default value to 0 in that field but it still does not work. I tried to talk with Adobe support and they were unable to help since the error involved a Javascript; even though I'm only using basic calculations within Adobe.  

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
January 29, 2024

This error is caused when you divide by zero and try to apply the result to a Number or Percentage field.

You must use a custom calculation script to check the divisor is not zero and only then proceed with the calculation.

In addition, there are multiple errors in your calculation scripts. Check the JS Console for more details.

Participant
January 30, 2024

Thank you for your input. Do you know what custom calculation script I must use? I've enable the JS Console but still not sure what to do with they recommendations.   

 

SyntaxError: missing ) in parenthetical
1:Field:Calculate
TypeError: getField(...) is null
1:Field:Calculate

try67
Community Expert
Community Expert
January 30, 2024

My version contains some more information:

 

SyntaxError: missing ) in parenthetical
1:Field:Calculate
TypeError: getField("Self_Pay") is null
1:Field:Calculate

 

I can't help you with the first one, but if you didn't use a script it probably comes from a calculation that involves a field with parentheses in its name. Such characters need to be escaped in the Simple Field Notation, by adding a back-slash before them.

The latter error is for a missing field name. You probably renamed it or didn't enter it correctly in the formula.

 

As for the calculation script, here's the basic code that does it:

 

var v1 = Number(this.getField("FieldName1").valueAsString);
var v2 = Number(this.getField("FieldName2").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;
Participant
January 29, 2024
New_fillable_form_Forum.pdf