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

validate code for multiples

New Here ,
Sep 26, 2018 Sep 26, 2018

what is the javascript validation code for multiples of 6.  I have created a fillable order form in acrobat and certain items can only be ordered in multiples of 6. So i want the quantity field to only accept numbers that are divisible by 6.  thanks

TOPICS
Acrobat SDK and JavaScript
459
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 ,
Sep 26, 2018 Sep 26, 2018

Use this code as the field's custom validation script:

if (Number(event.value)%6!=0) {

    app.alert("You must enter a value that's a multiple of 6.");

    event.rc = false;

}

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
New Here ,
Sep 26, 2018 Sep 26, 2018

THANK YOU! 

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 ,
Sep 26, 2018 Sep 26, 2018

You might want to add checks for a minimum value (e.g., 6, since -18 % 6 = 0) and a maximum as well, and blank.

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 ,
Sep 26, 2018 Sep 26, 2018
LATEST

Good point, although the code above will accept blank values.

If the list of possible allowed items is quite limited I would recommend using a drop-down, instead of a text field.

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