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

How to remove underscores from a form field?

Guest
Feb 08, 2019 Feb 08, 2019

Let me preface this by saying that I am not a coder by any means. I am trying to create a form that auto-fills two fields based on a selection made from a drop down box. The drop down box includes a list of three account names: Health Plan, Retirement Plan, and Disability & Survivor Plan. I can get the auto-fill fields to populate only when the items have underscores in their names (ie - Health_Plan, Retirement_Plan, and Disability_&_Survivor_Plan). The underscores are fine for coding purposes, but I do not want them to appear on the form - I would rather them show up with spaces. Is this possible? How can I achieve this?

TOPICS
PDF forms
1.2K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 08, 2019 Feb 08, 2019

Ha, I knew it!

The tutorial that explains how to use this code has a problem. It assumes that the field names don't contain any spaces in them, which means you can get away with stuff like this:

Health_Plan:{ FurtherCredit: " HP-ABERDEEN_EM_EQUI", Acct: "444444" },

By really, every string needs to be placed inside of double-quotes, like this:

"Health_Plan":{ "FurtherCredit": " HP-ABERDEEN_EM_EQUI", "Acct": "444444" },

If you do that then you would be able to include spaces in the field names and it will still work... For example:

"Health Plan":{ "FurtherCredit": " HP-ABERDEEN_EM_EQUI", "Acct": "444444" },

View solution in original post

Translate
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 ,
Feb 08, 2019 Feb 08, 2019

First of all, form fields don't appear on the form when you're not in Prepare Form mode, so it shouldn't matter.

Second of all, it sounds like you're already using a script to do it (I have a guess which one...). If that's the case, please post the code.

Translate
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
Guest
Feb 08, 2019 Feb 08, 2019

My first field is titled "Account Name" (AcctName) - it includes a dropdown box for the user to select Health Plan, Retirement Plan, or Disability & Survivor Plan. Based on the selection the user makes, the field Further Credit is populated, as well as Account number.

This is the JavaScript:

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<Document-Level>
//<ACRO_source>SetFieldValues</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:SetFieldValues ***********/

// Place all pre-population data into a single data structure
var AcctData = { Disability_and_Survivor_Plan:{ FurtherCredit: "DSP-ABERDEEN-EM_EQU", Acct: "5555555" }, Health_Plan:{ FurtherCredit: " HP-ABERDEEN_EM_EQUI", Acct: "444444" }, Retirement_Plan :{ FurtherCredit: "RP-ABERDEEN-EM_EQUI", Acct: "333333" }};
function SetFieldValues(cAcctName) {
    // Populate fields with values from the Acct Data Object
    this.getField("FurtherCredit").value = AcctData[cAcctName].FurtherCredit;
    this.getField("Acct").value = AcctData[cAcctName].Acct}

//</ACRO_script>
//</Document-Level>

//<AcroForm>
//<ACRO_source>AcctName:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:AcctName:Keystroke ***********/

if( event.willCommit )
{
   if(event.value == " ")
     this.resetForm(["FurtherCredit","Acct"]);
   else
     SetFieldValues(event.value);
}

//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>AcctName:Validate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:AcctName:Validate ***********/
event.value=event.value.replace(/_/g,"*");
//</ACRO_script>
//</AcroForm>

Translate
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 ,
Feb 08, 2019 Feb 08, 2019

Ha, I knew it!

The tutorial that explains how to use this code has a problem. It assumes that the field names don't contain any spaces in them, which means you can get away with stuff like this:

Health_Plan:{ FurtherCredit: " HP-ABERDEEN_EM_EQUI", Acct: "444444" },

By really, every string needs to be placed inside of double-quotes, like this:

"Health_Plan":{ "FurtherCredit": " HP-ABERDEEN_EM_EQUI", "Acct": "444444" },

If you do that then you would be able to include spaces in the field names and it will still work... For example:

"Health Plan":{ "FurtherCredit": " HP-ABERDEEN_EM_EQUI", "Acct": "444444" },

Translate
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
Guest
Feb 08, 2019 Feb 08, 2019
LATEST

You are a genius! This worked! Thank you so much!

Translate
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