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

how to add JS Titlecase code to according TextBox field

Participant ,
Jul 08, 2016 Jul 08, 2016

Hi All.

I created my first form in Acrobat XI Pro. How to add JavaScript Title-Case code to txtLastName text field?

Thanks.

TOPICS
Acrobat SDK and JavaScript , Windows
1.7K
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

correct answers 1 Correct answer

LEGEND , Jul 13, 2016 Jul 13, 2016

Open the Form tools or Prepare Form.

Select the form field to modify

User right mouse click to bring up context menu

Select Properties

Select Format tab

Select Custom format option

Select the Custom Format option

Cut and paste the script into the pop-up edit window

Click OK

I would force the value of the field to lower case before applying the RegExp to capitalize the 1st letter of each word.

str = event.target.value;

str = str.toLowerCase();

event.value = str.replace(/(^|\s|[\-\,\.]).{1}/g,function(cWrd){r

...
Translate
LEGEND ,
Jul 08, 2016 Jul 08, 2016

You need to write custom JavaScript. It should be best done in the custom format or on blur actiion. You may also need to adjust for parts of the last nsme like von, de, etc that might not need to have the first letter capitalized.

When I tested this and the name was all caps, the letters following the first character remained capitalized.

Using the format action will only change the displayed value of the form. You would need to use the custom calculation script or the on blur action to change the acual value of the field.

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 ,
Jul 09, 2016 Jul 09, 2016

Hi.

You can use this JavaScript as a Custom Format Script :

str = event.target.value;

event.value = str.replace(/(^|\s|[\-\,\.]).{1}/g,function(cWrd){return cWrd.toUpperCase()});

(Special thanks to Thom Parker)

Also see these topics :

- Uppercase the first letter only in a field using JS (JavaScript)

- Adobe Forms Title Case Exceptions using javascript (JavaScript)


Acrobate du PDF, InDesigner et Photoshoptographe
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
Participant ,
Jul 12, 2016 Jul 12, 2016

Hi JR_Boulay. Thanks for replay.

What need to do apply Custom Format Script to according TextBox field?

Thanks.

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
LEGEND ,
Jul 13, 2016 Jul 13, 2016

Open the Form tools or Prepare Form.

Select the form field to modify

User right mouse click to bring up context menu

Select Properties

Select Format tab

Select Custom format option

Select the Custom Format option

Cut and paste the script into the pop-up edit window

Click OK

I would force the value of the field to lower case before applying the RegExp to capitalize the 1st letter of each word.

str = event.target.value;

str = str.toLowerCase();

event.value = str.replace(/(^|\s|[\-\,\.]).{1}/g,function(cWrd){return cWrd.toUpperCase()}); 

This will prevent having all the entry in Upper case when one enters the value in all Upper Case.


					
				
			
			
				
			
			
			
			
			
			
			
		
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
Participant ,
Jul 13, 2016 Jul 13, 2016
LATEST

Hi gkaiseril. Thanks for help.

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