Copier le lien dans le Presse-papiers
Copié
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!
Copier le lien dans le Presse-papiers
Copié
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;}
}
Copier le lien dans le Presse-papiers
Copié
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.
Copier le lien dans le Presse-papiers
Copié
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.
Copier le lien dans le Presse-papiers
Copié
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?
Copier le lien dans le Presse-papiers
Copié
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.
Copier le lien dans le Presse-papiers
Copié
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;}
}
Copier le lien dans le Presse-papiers
Copié
That worked perfectly for what I was trying to do. You're a genius! Thank you again!
Trouvez plus d’idées, d’événements et de ressources dans la nouvelle communauté Adobe
Explorer maintenant