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

validate code for multiples

New Here ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

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

Views

302

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
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

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;

}

Votes

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

Copy link to clipboard

Copied

THANK YOU! 

Votes

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

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

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.

Votes

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
community guidelines