Copy link to clipboard
Copied
Hi All.
I created my first form in Acrobat XI Pro. How to add JavaScript Title-Case code to txtLastName text field?
Thanks.
1 Correct answer
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi JR_Boulay. Thanks for replay.
What need to do apply Custom Format Script to according TextBox field?
Thanks.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi gkaiseril. Thanks for help.

