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

Field validation query, help required please...

Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Hi there,

A quick question regarding text field validation, please can someone point me in the right direction?

I'm trying to validate a text field, that's a comb of 2 characters, to only allow values from 01 - 11.

Setting the form field format to number means losing the leading zero which I'd like to keep.

So far I've come up with this...

event.rc = true;
if (event.value != "" && event.value != "01" && event.value != "02" && event.value != "03" && event.value != "04" && event.value != "05" && event.value != "06" && event.value != "07" && event.value != "08" && event.value != "09" && event.value != "10" && event.value != "11")
{
    app.alert("The entered value needs to be from 01 to 11.");
    event.rc = false;
}

This code does what I need however it allows the user to enter anything into the field because there is no format on it.

Is there a nicer way to restrict the user to entering numbers only, check the value is from 01-11 and retain the leading zero?

 

Thanks in advance 🙂 

TOPICS
Acrobat SDK and JavaScript , Mac

Views

177

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

correct answers 1 Correct answer

Contributor , Aug 11, 2022 Aug 11, 2022

Whilst looking for something else I found this...

https://community.adobe.com/t5/acrobat-discussions/restricting-form-field-to-numbers-without-separators-on-xi/td-p/10310570

... which answers my question using a custom Keystroke script 🙂

Votes

Translate

Translate
Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

LATEST

Whilst looking for something else I found this...

https://community.adobe.com/t5/acrobat-discussions/restricting-form-field-to-numbers-without-separat...

... which answers my question using a custom Keystroke script 🙂

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