Text Field Properties - Insert degree symbol after field has been filled out with a number like 180

Community Beginner ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

I have a text field created and when someone fills it out I want the degree symbol to show up after.

For example, if someone enters the number 180 I want the degree symbol to show up so it looks like 180°.

When I open up Text Field Properties > Format, which one do I use (Custom format script: or Custom keystroke Script" and what is the javascript code for this to occur?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

249

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

LEGEND , Jun 01, 2018 Jun 01, 2018
Make sure you have copied the presented code exactly. There is a shortcut being used to append the "°" symbol.Or you can use:if (event.value != "") event.value = event.value +  "°";

Likes

translate

Translate

Translate
Most Valuable Participant ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

Use this code as the field's custom Format script:

if (event.value) event.value += "°";

Likes

translate

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
community guidelines
Community Beginner ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

The code is working in regards to placing a degree symbol after the number. The issue occurring now is if I fill the field out as 180, it changes the number to 0 so it looks like  0°. Is there a way to stop this from occurring?

Likes

translate

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
community guidelines
Most Valuable Participant ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

I tried it and it's not doing that. Make sure you remove any other code you added to that field.

Likes

translate

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
community guidelines
LEGEND ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

Make sure you have copied the presented code exactly. There is a shortcut being used to append the "°" symbol.

Or you can use:

if (event.value != "") event.value = event.value +  "°";

Likes

translate

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
community guidelines
Community Beginner ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

Thank you, this one works perfectly.

Likes

translate

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
community guidelines