2 Replies Latest reply on Jan 16, 2009 1:38 PM by George_Johnson

    Add (concatenate) a string to the end of a numerical field value (custom format script)?

    Level 1
      Hello All!

      1) I have a form field where a customer can input mileage (e.g. 48,000)
      I would like to be able to dynamically place the comma in the proper place as well as add " miles" to the end of the value the user input.
      For example:
      If the user types "123456" into the field, I would like for it to display as "123,456 miles"

      I assume this will require some custom format javascript... I'm familiar with the general syntax of JavaScript, but don't really know specific keywords/object names to use, I have a few custom calculation scripts in the form, and I've done some simple thing like concatenate two fields into one, etc.

      But this is a little different, because I'm only working with data from one field. I tried:

      event.value += " miles";

      However, this causes " miles" to get added everytime ANY field changes... so I end up getting "123,456 miles miles miles miles" as the user makes changes to other fields.

      2) Also, to further complicate things, is it possible to "remove" the custom formatting when the field gains focus? For example, if you use Acrobat's default number format ($1,394.00) on a field, when the user selects that field to edit the value, the formatting "disappears" so that the user would only see "1394".
      I would like to achieve the same with my custom field, so when the user selected the field that displays "123,456 miles" to change the value, they would only see/edit "123456"

      A bit wordy, I know, but thanks for any help!