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

Need a custom format in a field, such as A19-001 or B19-001

Community Beginner ,
Jun 18, 2019 Jun 18, 2019

I'm trying to set a custom format in a field, such as A19-001 or B19-001 which the user will enter. The "001" is a rolling number so it'll increase, but I want it to reject any other format. I'm using Adobe Acrobat Pro. I've searched but no luck. Any help? Thanks in advance!

TOPICS
PDF forms
641
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
1 ACCEPTED SOLUTION
Community Expert ,
Jun 18, 2019 Jun 18, 2019

OK, then you can use this code as the custom validation script of your field:

if (event.value) {

    if (/^[AB]\d{2}-\d{3}$/.test(event.value)==false) {app.alert("Error! Invalid value."); event.rc = false;}

}

View solution in original post

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 ,
Jun 18, 2019 Jun 18, 2019

So it is a value entered by the user, or an automatically calculated value? Or do you want the user to be able to change the value, but only to something specific? If the latter, I recommend you use a button to change the field's value for the user, so they have no way of messing it up and you can control exactly what it is. Each time the user clicks the button, the value of the field gets incremented by one.

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 Beginner ,
Jun 18, 2019 Jun 18, 2019

I would like the value to be entered by the user with the format as indicated and reject anything else, including too many or not enough characters. The auto increment box won't work for what I'm trying to do as it isn't always one digit higher for the user. So I want it to accept A19-001 or B19-001 (plus the increments for the digits) but nothing else. Hopefully that made sense.

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 ,
Jun 18, 2019 Jun 18, 2019

So it is only A or B at the start? Or any (upper-case) letter? And is it always followed by two digits, then a hyphen, then three digits?

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 Beginner ,
Jun 18, 2019 Jun 18, 2019

Yes, that is correct. Only starting with A or B, the two digit year so that'll change each year, a hyphen, then three digits.

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 ,
Jun 18, 2019 Jun 18, 2019

OK, then you can use this code as the custom validation script of your field:

if (event.value) {

    if (/^[AB]\d{2}-\d{3}$/.test(event.value)==false) {app.alert("Error! Invalid value."); 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
Community Beginner ,
Jun 18, 2019 Jun 18, 2019
LATEST

That worked perfectly for what I was trying to do. You're a genius! Thank you again!

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