Copy link to clipboard
Copied
Hi, i want to add a condition to a text field. so it should only allow to type "Y" , "N" or "U". can u pls help me to manage this work. thanks..
Copy link to clipboard
Copied
Does it needs to be achieved with a script?
You can achieve that with a a dropdown menu.
Just add the Y , N , U options in the list items and uncheck the box that says Allow users to type, then lock the field
Copy link to clipboard
Copied
Hi,
Just wondering if you were able to resolve your this exercise.
If your still looking for a condition I found this thread: https://community.adobe.com/t5/acrobat/how-to-allow-only-certain-characters-to-be-typed-in-a-field/t...
So you can modify your script like
if (event.change) {
event.rc = /^[N,n,U,u,Y,y]/.test(event.change);
}
//if you need to restrict the N, U and Y letters to uppercase only modify the script above like this:
if (event.change) {
event.rc = /^[N,U,Y]/.test(event.change);
}
//PLAYING AROUND WITH THIS LITTLE SCRIPT I NOTICED THAT THIS ALSO WORKS
if (event.change) {
event.rc = /^[N,n,U,u,Y,y]/.test(event.change);
}
event.change = event.change.toUpperCase();
If you are using the dropdown menu method like I suggested in my first reply, and you are allowing users to also enter their own text and need to restrict the them to typen only one of those three letters see image below: