How to Automatically Capitalize the First Letter in PDF Form Fields
Question details
The user needs a method to configure a PDF form field so that the first letter of every entered word is automatically capitalized, and the remaining letters are converted to lowercase.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form that requires standardized text formatting, such as names or titles, to ensure uniform data collection.
- Observed behavior
- Text entered into the PDF form field needs to be automatically reformatted to Title Case upon submission or when the field loses focus.
Ensure you are using a PDF editor that supports form field properties and custom JavaScript validation, and verify that you have edit permissions for the PDF document.
Apply a Custom JavaScript Validation Script to the Form Field
Use a custom JavaScript snippet in the field's validation properties to automatically format the entered text to Title Case.
This method utilizes a straightforward script that triggers when the user finishes typing in the field. It splits the inputted string by spaces, capitalizes the first character of each segment, makes the remaining characters lowercase, and then rejoins them into a formatted sentence.
Open your PDF in edit mode, right-click the target text form field, and select 'Properties' from the context menu.
In the Text Field Properties dialog box, click on the 'Validate' (or 'Validation') tab to set up custom behavioral rules.
Select the option 'Run custom validation script' and click the 'Edit' button to open the JavaScript editor window.
Paste the following script: var str = event.value; var words = str.split(' '); for (var i in words) { var word = words[i]; word = word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); words[i] = word; } event.value = words.join(' ');
Click 'OK' to save the script, close the properties window, and test the form field by typing in lowercase names or hyphenated words to ensure they capitalize correctly.

Easily Manage PDF Form Fields with WPS Office
WPS Office provides robust PDF editing capabilities, allowing you to create fillable forms, adjust field properties, and manage text formatting seamlessly. It is fully compatible with standard PDF features and JavaScript validations.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document containing the interactive form you want to edit.
- 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to access all interactive form field creation and editing tools.
- 3. Modify field properties: Double-click the specific text field to open its properties menu and adjust formatting, appearance, or validation rules as needed.
- 4. Save your interactive PDF: Once your fields are properly configured, save the document to lock in the formatting rules for future users.

Frequently Asked Questions
Can I format the text to all uppercase instead?
Yes. If you want all letters to be capitalized automatically, you can simply change the script to: event.value = event.value.toUpperCase(); or check if your PDF editor has a built-in 'Force Uppercase' option under the field's formatting or options tab.
Why isn't the JavaScript running when I type in the PDF?
JavaScript might be disabled in your PDF viewer's security settings. Ensure that 'Enable Acrobat JavaScript' or the equivalent script execution setting in your PDF reader is turned on.
Will this auto-capitalize script work on mobile PDF readers?
It depends on the application. While advanced desktop PDF editors and readers support JavaScript validation, many standard mobile PDF viewers do not execute custom scripts. It is always recommended to test your forms on the platforms your audience is likely to use.




