Skip to main content
Participant
March 6, 2024
Answered

'The value entered does not match the format of the field' Error - I need help

  • March 6, 2024
  • 1 reply
  • 840 views

Hello,

 

I am currently new to the prepare forms feature and new overall to the Adobe Cloud. 

 

I have tried to create a document in which, you can calculate the percentage of the mark you achieved on a test. For instance, scoring 20 out of 40 total marks would give a result of 50%.

 

For the formula, I used the following: 

(Text66/Text67)*1

Text66 is the achieved score

Text67 is the total marks 

 

At first, it worked, but as I started to add all the other text fields, it has hissy fit and now throws up the error. 

 

Any help would be appreciated. 

 

Many Thanks in advance.

This topic has been closed for replies.
Correct answer Nesa Nurani

When field "Text67" is empty or 0 it still tries to calculate, and you can't divide by zero so that's why error, you will have to use custom calculation script instead, and set field value to 0 if "Text67" is 0:

var t66 = Number(this.getField("Text66").valueAsString);
var t67 = Number(this.getField("Text67").valueAsString);

if(t67 === 0)
 event.value = 0;
else
 event.value = (t66/t67)*1;

What is the point of multiply by 1?

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 6, 2024

When field "Text67" is empty or 0 it still tries to calculate, and you can't divide by zero so that's why error, you will have to use custom calculation script instead, and set field value to 0 if "Text67" is 0:

var t66 = Number(this.getField("Text66").valueAsString);
var t67 = Number(this.getField("Text67").valueAsString);

if(t67 === 0)
 event.value = 0;
else
 event.value = (t66/t67)*1;

What is the point of multiply by 1?

Participant
March 7, 2024

Thank you so much, this has worked!

I know I am unsure too, why I multiplied by 1 which is the same answer. 

 

Thank you again.