How to Display a JavaScript Alert on a PDF Radio Button or Checkbox Selection
Question details
The user needs to configure a PDF form to display an informational popup dialog only when a specific radio button or checkbox option (e.g., "Ambulance") is selected.

- Product
- Adobe Acrobat PDF Forms
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where users need immediate guidance or notification upon selecting a designated option.
- Observed behavior
- The form requires a script that strictly runs for the targeted option, displaying a standard alert dialog with an OK button.
Ensure your PDF editor supports form creation and JavaScript execution, and verify the exact export value of the radio button or checkbox you wish to target.
Add a Mouse Up JavaScript to the Radio Button Field
Use Adobe Acrobat's built-in app.alert function attached to a Mouse Up action to check the value of the selected field and display a custom message.
This approach utilizes a conditional JavaScript statement tied to the radio button's interaction events. It checks if the clicked option matches your target value before triggering the dialog box.
Open your PDF document in your advanced PDF editor and navigate to the 'Prepare Form' or 'Form Editing' tool.
Right-click the specific radio button or checkbox field you want to modify and select 'Properties' from the context menu.
Go to the 'Actions' tab. Select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the action dropdown menu, and click the 'Add' button.
In the JavaScript editor, enter the following code: if (event.target.value == "ambulance") app.alert("You must contact the HR Department immediately.", 3); then click OK to save your changes.

Easily Manage Interactive PDF Forms with WPS Office
If you need a reliable and lightweight tool to fill, manage, and edit standard PDF forms, WPS Office provides an intuitive PDF Editor that handles interactive fields efficiently.
- 1. Open your PDF file: Launch WPS Office and open your interactive PDF document using the built-in WPS PDF tool.
- 2. Navigate to form tools: Click on the 'Form' tab in the top ribbon to view all available interactive form fields and highlight editable sections.
- 3. Fill or edit the document: Interact with checkboxes, radio buttons, and text fields directly. Double-click fields to view basic properties.
- 4. Save the filled form: Click 'Save' or 'Export to PDF' to preserve your inputs and ensure form stability for the next viewer.

Frequently Asked Questions
Why doesn't the JavaScript alert dialog have an 'X' close button?
The standard Acrobat app.alert function generates a strict modal dialog. By design, this requires direct user acknowledgment, so it only features an 'OK' button and intentionally omits the 'X' button to ensure the user reads the message.
What does the '3' mean in the app.alert JavaScript code?
In Acrobat's JavaScript API, the second parameter of app.alert determines the icon displayed in the dialog. The number '3' represents an 'Information' icon. Other values include 0 for Error, 1 for Warning, and 2 for Question.
Can I use this same script for a PDF checkbox instead of a radio button?
Yes. You can attach a Mouse Up script to a checkbox. However, you must update the script to check against the checkbox's specific export value (for example, "Yes" or "On") rather than the radio button's value.




