Skip to main content
Hoey
Known Participant
December 28, 2017
Answered

Is it possible to convert a user input in a text box to change within the same text box once the user entered/tabbed out?

  • December 28, 2017
  • 1 reply
  • 1091 views

I am developing a scope sheet for a construction company.  I want to have the employee/user to get to the room size portion of the document to be able to put in: 5,3 to represent 5'3" but once they enter/tab out of that text box it converts to 5.25.  I can do last conversion (converting to a decimal) - I am stuck on having the "Feet,Inches" / "5,3" - represent 5'3" format.  I'm also up for any suggestions that would solve this issue any other way (and most likely easier since I always tend to make things complicated) - Thank you all in advance!

This topic has been closed for replies.
Correct answer try67

I apologize try67

I will use the value for a calculation.  The first one will be to calculate the total square footage of the room after they follow up and enter the width.  Some of the employees have issues with conversion to decimals and I want to make it simpler for them also so they don't have to ask for a way to do the conversion themselves. 


OK, then use this code as the field's custom validation script:

var v = event.value;

if (v!="") {

    var parts = v.split(",");

    if (parts.length==2) {

        event.value = Number(parts[0]) + Number(parts[1])/12;

    }

}

1 reply

try67
Community Expert
Community Expert
December 28, 2017

Sure, it's possible, but do you want to change the actual value, or just how it is presented?

In other words, if they enter "5,3", move out of the field and then move back into it, should the value they edit be "5.25" or the original "5,3"?

Hoey
HoeyAuthor
Known Participant
December 28, 2017

Thanks for the reply try67!

If they entered "5,3" move out and it should show "5.25" -  That would be amazing! Is it simple and I will add this to the list of things I over complicate/think?

try67
Community Expert
Community Expert
December 28, 2017

I understood that, but that's not what I asked about... Let me phrase it differently: Are you planning to use this value in a calculation of some kind (in which case it needs to be a decimal number), or is it just to make it easier for the user to enter it in a format they're familiar with?