How to Show Which Required PDF Form Field is Empty Before Submission
Question details
How to identify and display the specific empty required field in a PDF form prior to submission.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form and wanting to improve the user experience by specifying exactly which required field was missed during submission.
- Observed behavior
- The user wants to replace a generic 'Empty Message' prompt with a custom script alert that outputs the exact name of the uncompleted required field.
Ensure you have an advanced PDF editor that supports JavaScript execution and form field management, and verify that all your form fields have user-friendly names so the alert message is clear.
Implement a Custom JavaScript to Validate Required Fields
Use a custom validation script on your submit button to check all fields and alert the user with the specific name of the first empty required field.
By adding a document-level script or a mouse-up action script to your Submit button, you can iterate through all fields in the PDF. This replaces default generic error messages and guides the user directly to the missing information.
Open your PDF form in your advanced PDF editor and access the Form Editing tools.
Right-click your 'Submit' button and select 'Properties' from the context menu.
Go to the 'Actions' tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript' as the action. Click 'Add'.
In the JavaScript Editor window, paste the following script: for (var i = 0; i < this.numFields; i++) { var name = this.getNthFieldName(i); var field = this.getField(name); if (field.required && field.defaultValue == field.value) { app.alert("Field " + name + " is empty"); break; } }
Click 'OK' to save the script, close the properties window, and exit form editing mode. Test the form by leaving a required field empty and clicking Submit.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides powerful PDF editing tools that allow you to create interactive forms, set required fields, and easily manage document workflows without needing expensive software.
- 1. Install WPS Office: Download and install WPS Office, then open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access form creation and editing tools.
- 3. Add and Configure Fields: Add interactive fields like Text Fields or Buttons, double-click them to open Properties, and configure settings such as 'Required'.
- 4. Save Your Form: Save your fillable PDF form and share it effortlessly with your users.

Frequently Asked Questions
Why does my PDF only show a generic 'empty field' warning?
By default, many PDF viewers use a built-in generic prompt when a field marked as 'Required' is left blank. To customize this to show the exact field name, you need to override the default submit action using a custom JavaScript validation.
Can I highlight the empty field instead of just showing an alert popup?
Yes. You can modify the JavaScript to change the background or border color of the empty field. You would add a line like 'field.fillColor = color.red;' inside the 'if' condition of your script.
Does this JavaScript work on all PDF readers?
Most desktop PDF readers like Adobe Acrobat, WPS Office, and Foxit support PDF JavaScript. However, some mobile PDF viewers, default OS previewers, or web browser extensions might not execute JavaScript correctly, so the script may be ignored in those environments.
How do I name my fields properly for this script?
In Form Editing mode, open the Field Properties and edit the 'Name' box. It is best to use clear, descriptive names (like 'PhoneNumber' or 'Email Address') so the popup message is easy for the user to understand.




