Skip to main content
deckarduk
Inspiring
August 11, 2022
Answered

Field validation query, help required please...

  • August 11, 2022
  • 1 reply
  • 393 views

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 🙂 

This topic has been closed for replies.
Correct answer deckarduk

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 🙂

1 reply

deckarduk
deckardukAuthorCorrect answer
Inspiring
August 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 🙂