Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I hide error messages?

Community Beginner ,
Jun 16, 2017 Jun 16, 2017

I have a form and calculator I created. The calculations all work perfectly and sum correctly.

The problem is I get 2 error messages same message 2 different field entries.


Basic message: "Value does not match format".

These 2 messages pop-up with every field entry made until the entire calculator is filled. This even happens with the text only entries.

So as the calculator works, can I just hide the error messages?

If anyone wants to look at the calculator I can sen it to you.

Thank you for any help.

TOPICS
PDF forms
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jun 19, 2017 Jun 19, 2017

In that case you have to change this line:

if (v1 != 0) {

To:

if (v2 != 0) {

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2017 Jun 16, 2017

This error message typically appears when you try to apply a non-numeric value to a field set up as having a Number format.

Most likely, it's caused by an attempt to divide by zero, which yields a non-numeric result, since it's an illegal operation.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2017 Jun 16, 2017

Hi try67,

I thought that might be the issue. My calculator when the entries are cleared all say "0". So any numbers I put in until the form is filled is trying to divide from the number already in the field. How do I clear the field to say nothing?

Thx!

Sheryl

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 16, 2017 Jun 16, 2017

Hiding error messages can add more problems to your form. There tell you of an issue that probably needs to be addressed before your form of script will work properly.

You can set the problem field's format to "None" and observe the result of the division.

JavaScript supports some numeric values that do not comply to the "Number" format. They are "Infinity", "-Infinity" and scientific notation. Since these numbers are not in the format of numeric digits, sign and decimal point they do not match the "Number" format. You will need to add code to avoid division by zero or allow the non "Number" format values.

Setting the field to a null string will not eliminate the error since a null string will be treated as a zero in JavaScript. You need to use an "if" statement to see if the divisor is not zero before performing any division. This requires custom JavaScript coding.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2017 Jun 16, 2017

Hi gkaiseril,

I tried javascript which worked in the sense the error messages were gone, but the calculations were wrong.

Example currently using in:

Excel: BC14=BC13/BC12

Acrobat: BC13/BC12 Go to: BC14

So I changed to JavaScript.

This is the JavaScript used, but it is not giving me the correct answer when calculated. (No error messages).

function () {  // Get the field values, as numbers   
  var v1 = +getField("BC13").value;
  var v2 = +getField("BC12").value; 

  if
(v1 !== 0)
  { event.value = 100 * (v1 - v2) / v1; }
  else { event.value = "";
  } 
})();

I reached out to others and this was the suggestion made:

change +getfield to .getfield

I did make the change and got syntex error messages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2017 Jun 16, 2017

Why all of this?

event.value = 100 * (v1 - v2) / v1;

Just use:

event.value = v2 / v1;

The rest of the code is fine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2017 Jun 16, 2017

Yes this makes sense:

function () { // Get the field values, as numbers

var v1 = +getField("BC13").value;

var v2 = +getField("BC12").value;

if (v1 !== 0)

{ event.value = v2 / v1; }

else { event.value = "";

}

})();

I now get:

SyntaxError: function statement requires a name

1: at line 2

for this line

var v1 = +getField("BC13").value;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2017 Jun 16, 2017

You don't need the function definition. Use this code:

var v1 = Number(this.getField("BC13").value);

var v2 = Number(this.getField("BC12").value);

if (v1 != 0) {

    event.value = v2 / v1;

} else {

    event.value = "";

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2017 Jun 19, 2017

Thank you try67,

I had to flip the values to calculate properly

Suggested: event.value = v2 / v1;

Flipped: event.value = v1 / v2;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2017 Jun 19, 2017

In that case you have to change this line:

if (v1 != 0) {

To:

if (v2 != 0) {

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 19, 2017 Jun 19, 2017
LATEST

Hi try67,

It works both ways and calculates properly.

Thank you so very much for your help.

Best,

Sheryl

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines