How can I set a text field to convert all text entered to upper case when populated? | Community
Skip to main content
Level 2
September 6, 2013
Solved

How can I set a text field to convert all text entered to upper case when populated?

  • September 6, 2013
  • 34 replies
  • 28828 views

I want to have all entered text populated into specific text fields to automatically convert to upper case. I am working in LiveCycle Designer ES2.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jcytrny

I am not sure how to place the code to get it working. Cannot get it to work.

34 replies

Level 4
September 7, 2013

Hi,

Place the following code in the change event of textfield to make the input in upper case

xfa.event.change=xfa.event.change.toUpperCase();

Hope it helps

jcytrnyAuthor
Level 2
September 7, 2013

Thank you for your assistance.

Where is the change event to place the code? I pasted the code into the function area but it did nothing.

Joe

Level 4
September 7, 2013

Please check the code in the uploaded the file 

https://workspaces.acrobat.com/?d=1vGCuh5UZeV4RMtV0Idt7g

jcytrnyAuthor
Level 2
September 7, 2013

Cannot open the document using the link. Says my Adobe cannot support the document. I have Adobe Reader X and Acrobat Pro X installed on my computer.

Level 4
September 7, 2013

I have attached the screenshot of the code

jcytrnyAuthor
Level 2
September 7, 2013

Thank you. All working now. Had a wrong setting before.

jcytrnyAuthor
Level 2
September 7, 2013

Thanks again. Can this code work for Proper case if I just change the code text from UpperCase to ProperCase?

Level 4
September 9, 2013

Use the below code on exit event of textfield

if (!(this.isNull || this.rawValue == "")) {

      var str = this.rawValue;

     var char1 = str.substring(0,1);

     var char2_n = str.substring(1,str.length);

      this.rawValue = char1.toUpperCase() + char2_n.toLowerCase();

}

Thanks,

Vipin

jcytrnyAuthor
Level 2
September 9, 2013

Thank you. Works only for the first word. All words after the first word remain in all lower case. The fields being populated contain names of organizations and all first letters of the major words need to be capitalized. Also will be used for fields populating names of people if it works so both first and last names will need to be proper case.

Level 4
September 9, 2013

You shouls use this script

function capitalizeEachWord(str)

{

   var words = str.split(" ");

   var arr = Array();

   for (i in words)

   {

      temp = words[i].toLowerCase();

      temp = temp.charAt(0).toUpperCase() + temp.substring(1);

      arr.push(temp);

   }

   return arr.join(" ");

}

and call as

upper.rawValue= js.capitalizeEachWord(this.rawValue);

Also i have uploaded the PDF

https://workspaces.acrobat.com/?d=54*PMvnV4z9bIjJ5siGiEw

Thanks,

Vipin