enter Y for yes N for no

Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

I have this one text field I want the user to enter Yes or No. To save time is there a javascript to allow Yes to be entered when they just type in y or n so then No would get populated in the same field. I use to have a drop down, but I don't want to use that option. Does anyone know a little javascript that would enable me to do this? Thanks.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use this code as the field's custom Format script:

if (event.value.toUpperCase()=="Y") event.value = "Yes";

else if (event.value.toUpperCase()=="N") event.value = "No";

else event.value = "";

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

221

Likes

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

enter Y for yes N for no

Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

I have this one text field I want the user to enter Yes or No. To save time is there a javascript to allow Yes to be entered when they just type in y or n so then No would get populated in the same field. I use to have a drop down, but I don't want to use that option. Does anyone know a little javascript that would enable me to do this? Thanks.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use this code as the field's custom Format script:

if (event.value.toUpperCase()=="Y") event.value = "Yes";

else if (event.value.toUpperCase()=="N") event.value = "No";

else event.value = "";

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

222

Likes

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
Mar 03, 2019 0
Most Valuable Participant ,
Mar 03, 2019

Copy link to clipboard

Copied

You can use this code as the field's custom Format script:

if (event.value.toUpperCase()=="Y") event.value = "Yes";

else if (event.value.toUpperCase()=="N") event.value = "No";

else event.value = "";

Likes

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
Reply
Loading...
Mar 03, 2019 1
Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

Works perfectly, exactly what I was looking for, thanks again Gilad.

Likes

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
Reply
Loading...
Mar 03, 2019 0
Most Valuable Participant ,
Mar 03, 2019

Copy link to clipboard

Copied

You're welcome. Just keep in mind this code doesn't change the actual value of the field, only the display value.
If you want to change the actual value use it as a Calculation script.

Likes

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
Reply
Loading...
Mar 03, 2019 0
Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

ok. I'll try it both ways to fully understand what this means. Thanks.

Likes

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
Reply
Loading...
Mar 03, 2019 0
Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

Hi Gilad, just another quick question regarding this script. I have at least a dozen different sizes like 1 5/8", 2 3/8", 2 78", 4", etc. How can I apply this bit of code to do the same this as with the yes/no. Is is possible to use an alphabet code like - type into the text field (a) for 1 5/8", (b) for 2 3/8", (c) for 2 7/8" and so on and the last option would be other?

Likes

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
Reply
Loading...
Mar 03, 2019 0
Most Valuable Participant ,
Mar 03, 2019

Copy link to clipboard

Copied

Sure. There doesn't have to be any relation between the entered value and the new one.

For example:

if (event.value.toUpperCase()=="A") event.value = "1 5/8\"";

Likes

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
Reply
Loading...
Mar 03, 2019 1
pdfUser1 LATEST
Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

Yeah, I got it. This is a very cool feature. My job just got easier. Thanks, bro.

Likes

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
Reply
Loading...
Mar 03, 2019 0