Highlighted

The value entered does not match the format of the field; java script

New Here ,
Feb 19, 2018

Copy link to clipboard

Copied

I created a custom script that equates a percentage and that works fine. However, I get the error message of "the value entered does not match the format of the field". I believe that by other discussions I have read that I need to set a script that ensures the field has a non-zero value but don't know how to write it. My current calculation is: event.value = this.getField("Sponsor Total").value/this.getField("Overall Project Total").value

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

var numerator = +getField("Sponsor Total").value;

var denominator = +getField("Overall Project Total").value;

event.value = denominator !== 0 ? numerator / denominator : "";

That last line translated to English would be: If the denominator is not equal to zero, set this field's value to the numerator divided by the denominator. Otherwise, make it blank.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

691

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

The value entered does not match the format of the field; java script

New Here ,
Feb 19, 2018

Copy link to clipboard

Copied

I created a custom script that equates a percentage and that works fine. However, I get the error message of "the value entered does not match the format of the field". I believe that by other discussions I have read that I need to set a script that ensures the field has a non-zero value but don't know how to write it. My current calculation is: event.value = this.getField("Sponsor Total").value/this.getField("Overall Project Total").value

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

var numerator = +getField("Sponsor Total").value;

var denominator = +getField("Overall Project Total").value;

event.value = denominator !== 0 ? numerator / denominator : "";

That last line translated to English would be: If the denominator is not equal to zero, set this field's value to the numerator divided by the denominator. Otherwise, make it blank.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

692

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
Feb 19, 2018 0
Adobe Community Professional ,
Feb 19, 2018

Copy link to clipboard

Copied

var numerator = +getField("Sponsor Total").value;

var denominator = +getField("Overall Project Total").value;

event.value = denominator !== 0 ? numerator / denominator : "";

That last line translated to English would be: If the denominator is not equal to zero, set this field's value to the numerator divided by the denominator. Otherwise, make it blank.

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...
Feb 19, 2018 0
New Here ,
Feb 20, 2018

Copy link to clipboard

Copied

Thank you, George...worked like a charm!

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...
Feb 20, 2018 0
Adobe Community Professional ,
Oct 20, 2020

Copy link to clipboard

Copied

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...
Oct 20, 2020 0