PDF Editing Issues

How to Display a JavaScript Alert on a PDF Radio Button or Checkbox Selection

Algirdas JasaitisAlgirdas Jasaitis Nov 2, 2026 869 views

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.

How to Display a JavaScript Alert When a PDF Checkbox or Radio Button 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.
Before you start

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.

Solution 1Recommended

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.

1
Enter form editing mode

Open your PDF document in your advanced PDF editor and navigate to the 'Prepare Form' or 'Form Editing' tool.

2
Open field properties

Right-click the specific radio button or checkbox field you want to modify and select 'Properties' from the context menu.

3
Configure the Mouse Up action

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.

4
Input the JavaScript code

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.

Add a Mouse Up JavaScript to the Radio Button Field
Dialog Box Interface Limitations: Acrobat's standard app.alert dialog box does not provide a separate 'X' close button in the corner; users must click the 'OK' button to dismiss the notification.
Powerful PDF Form Management

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. 1. Open your PDF file: Launch WPS Office and open your interactive PDF document using the built-in WPS PDF tool.
  2. 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. 3. Fill or edit the document: Interact with checkboxes, radio buttons, and text fields directly. Double-click fields to view basic properties.
  4. 4. Save the filled form: Click 'Save' or 'Export to PDF' to preserve your inputs and ensure form stability for the next viewer.
Seamlessly fill and edit interactive PDF formsHighly compatible with standard Adobe PDF document formatsLightweight software with an intuitive, user-friendly interfaceCross-platform support for Windows, Mac, iOS, and Android
microsoft office alternative - wps office

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.