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

The value entered does not match the format of the field

Mentor ,
Dec 20, 2016 Dec 20, 2016

Okay, hopefully the last question of the day...

I've simplified my problem down to the following: I have two radio buttons that, when clicked, populate a combobox with a set of options. The first set consists of the numbers 1-5, and the second is simply the string "N/A". Then down below, a numeric Cost field will check to see if the contents of the Quantity field is not "N/A", and if it's not, it will turn the quantity string into an integer and multiply it by 10. Otherwise, if it is "N/A", it will return 0.

The problem is that, as soon as you click on either radio button, Acrobat gives the error "The value entered does not match the format of the field [ Cost ]". So it sounds like Cost is expecting an integer and receiving a string, but I'm not sure why it would be getting a string. Other than that, it works as expected.

form diagram.jpg

TOPICS
Acrobat SDK and JavaScript
969
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

correct answers 1 Correct answer

Community Expert , Dec 20, 2016 Dec 20, 2016

Use this code for the Cost field:

var qty = this.getField("Quantity").valueAsString;

if (qty != "N/A") {

    event.value = Number(qty) * 10;

} else {

    event.value = 0;

}

Translate
Community Expert ,
Dec 20, 2016 Dec 20, 2016

Why is the Quantity field a drop-down if it has a calculated value? It would make more sense to use a text field.

Try changing the format of the Cost field to None and see what the results are.
If you can't get it to work please share the file with us.

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
Mentor ,
Dec 20, 2016 Dec 20, 2016

Changing the format of Cost to none does indeed eliminate the error. But I would really like the result to be formatted as a dollar amount, since that's the way the other fields on the page are formatted.

The Quantity field is a drop-down because I want the user to be able to select from a limited set of quantities. A text field would allow them to enter any quantity. The available quantities change based on what option they select.

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
Mentor ,
Dec 20, 2016 Dec 20, 2016

You can download the PDF here.

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 ,
Dec 20, 2016 Dec 20, 2016

Use this code for the Cost field:

var qty = this.getField("Quantity").valueAsString;

if (qty != "N/A") {

    event.value = Number(qty) * 10;

} else {

    event.value = 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
Mentor ,
Dec 20, 2016 Dec 20, 2016
LATEST

Perfect. Thank you so much. You've helped me a lot today!

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