10 Replies Latest reply on Jun 7, 2013 9:20 AM by glvmlss01

# The value entered does not match the format of the field

I have a PDF I have created for pay increases (i am very new to this),  i keep getting the error message "the value entered does not match the format of the field [Pay4]"

My fields are listed as:  Pay 1 is the current rate, Pay 2 is the new rate, Pay 3 is the amount of increase and Pay 4 is the % of increase.

Here is the calc script for Pay3:

var P1 = this.getField("Pay1").value;

var P2 = this.getField("Pay2").value;

var D1F = 0;

if (P1<=P2) {

D1F = P2-P1}

else {

D1F = P1-P2}

this.getField("Pay3").value = D1F;

and the scrip for Pay4:

var P1 = this.getField("Pay1").value;

var P2 = this.getField("Pay2").value;

if (P1 === 0) {P1 =1}

if (P2 === 0) {P2 =1}

var P3R = P1/P2*100;

var PERC3NT = 100 - P3R;

this.getField("Pay4").value = PERC3NT;

Once i enter the script in for Pay 4 i get the error message and it pops up after everything I enter.

• ###### 1. Re: The value entered does not match the format of the field

This usually happens when you try to divide by zero. You took some steps to

avoid that, but I don't think it's working.

You need to make sure you explicitly convert the values of the fields to

numbers, like so:

var P1 = Number(this.getField("Pay1").value);

var P2 = Number(this.getField("Pay2").value);

• ###### 2. Re: The value entered does not match the format of the field

I'd expect this if P2 is zero or not filled in. Your script needs to detect and prevent that case of dividing by zero, which is an error with surprising end results.

• ###### 3. Re: The value entered does not match the format of the field

And you seem to have an operator made from THREE equals signs... In fact I see this is really the problem, goodness knows what that will do...

• ###### 4. Re: The value entered does not match the format of the field

Actually, that's a valid operator. It checks both the value and the type of the variable ("Strict equals").

• ###### 5. Re: The value entered does not match the format of the field

Interesting, you learn something new everyday. Armed with my five minutes of new knowledge, I'd say that it is still the problem as it will prevent the otherwise automatic conversion of string to number that would have allowed a test for equality to numeric zero to succeed.

• ###### 6. Re: The value entered does not match the format of the field

Which is why I recommended converting the string to a Number object

explicitly...

On Fri, Jun 7, 2013 at 5:12 PM, Test Screen Name

• ###### 7. Re: The value entered does not match the format of the field

Maybe I did something worng.  I added your reccomendation above but now I am gettting a blank field when I fill in the others. Sorry, again this is all new to me so.

var P1 = number(this.getField("Pay1").value);

var P2 = number(this.getField("Pay2").value);

if (P1 === 0) {P1 =1}

if (P2 === 0) {P2 =1}

var P3R = P1/P2*100;

var PERC3NT = 100 - P3R;

this.getField("Pay4").value = PERCENT

• ###### 8. Re: The value entered does not match the format of the field

You've still got three = signs together. Why?

• ###### 9. Re: The value entered does not match the format of the field

You didn't copy my code properly. JS is case-sensitive...

Your current code should be producing errors. You should enable the option to show the console on warnings and errors (Edit - Prefs. - JavaScript).

• ###### 10. Re: The value entered does not match the format of the field

Thank you so much for all you help, it worked.