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

Need help turning a number entered into a PDF into feet and inches

New Here ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

Hi, I'm not a Javascript pro and am looking to add the symbol for feet, and inches into a PDF fillable form field.

To be clear, my client would like to enter the number of feet and have it return (appended) with the feet symbol as well as 0 inches.

So for example, if I were to input 30 into the field, I would like it to return the number formatted as  30' 0".

Any help is greatly appreciated! I know it's not a difficult script, but as I said, I am quite lost when it comes to js.

Thanks!

TOPICS
PDF forms

Views

1.3K

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

Community Expert , Jul 05, 2018 Jul 05, 2018

Use this:

if (event.value) event.value += "' 0\"";

Votes

Translate

Translate
Community Expert ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

You need to better explain how this is supposed to work. How would they enter 30' 6", for example? 30.5? 30.6? Something else?

Also, do you want to change the actual value of the field, or just how it is displayed? Or maybe use two separate fields? (I think that's a better approach, personally)

Votes

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
New Here ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

Thank you for responding try67!

They would like to enter the number, then have the number show up (unchanged) with the feet symbol, followed by 0" (inches will always be 0). They need to be in the same field.

So if they enter "50", it should appear on the form (in the text field) as 50' 0".

I have figured out how to get it to show in feet with the zero following, just having trouble getting the inch marks in as well...

Votes

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
New Here ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

I used the below to get it somewhat working...

// Custom Format script for text field 

if (event.value) event.value += "'" + "0";

Votes

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 Expert ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

Use this:

if (event.value) event.value += "' 0\"";

Votes

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
New Here ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

You are amazing, thank you!

Votes

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
New Here ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

What if one wanted to have it display 1'10"  entered as 1.10

Votes

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 Expert ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

Use this code:

 

if (event.value) event.value = event.value.replace("'", ".").replace("\"", "");

Votes

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
New Here ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

I think this code is converting backwards.

Votes

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
New Here ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

I got it to display 5' 2" on a field after entering 5 2 in the form field box

 

Code: if (event.value) event.value = event.value.replace(" ", "' ");if (event.value) event.value += "\"";

Votes

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
New Here ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

LATEST

Is it possible to use this without the user having to put a space between the numbers?

Votes

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