Automatically Check an SMS Box in an Adobe Acrobat Form
Question details
Automatically select an Allow SMS checkbox when a Mobile Number field contains a value, and clear it when the field is empty.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form creator wants a checkbox to respond to an entry in a mobile number field.
- Observed behavior
- The desired form behavior is for the SMS checkbox to reflect whether the mobile number field contains non-whitespace text.
Open the PDF in Adobe Acrobat and use Prepare a form to confirm that the mobile number and SMS checkbox fields exist. Check the checkbox's export value in its properties; the script must use that value rather than an assumed value.
Use a validation script to update the SMS checkbox
Use this approach to update the checkbox when a user commits a change to the mobile number field.
The validation script uses the value being entered in the mobile field and sets the checkbox to its export value or to Off. It checks only for non-whitespace text; it does not verify that the number is valid or active.
In Adobe Acrobat, open the PDF and choose All tools > Prepare a form.
Right-click the Allow SMS checkbox, choose Properties, and open the Options tab. Note its Export Value; the example script uses Yes.
Right-click the Mobile Number field and choose Properties > Validate. Select Run custom validation script, click Edit, and enter: var sms = this.getField("Allow SMS"); sms.value = String(event.value).replace(/^\s+|\s+$/g, "") ? "Yes" : "Off";
In the script editor, replace Allow SMS with the checkbox's exact field name and Yes with its actual export value. Click OK and close the field properties.
Use Preview in Prepare a form, enter a value in Mobile Number, and move focus out of the field. Confirm that Allow SMS is checked; then clear the number and move focus out again to confirm it is unchecked. Save the PDF.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Open existing files to make moving between office suites easier. WPS does not configure Acrobat's validation script, and PDF features may vary by plan.

Frequently Asked Questions
Why does the checkbox stay unchecked after I enter a number?
Move focus out of the Mobile Number field to commit the entry. If it still does not work, check the exact checkbox field name and its Options > Export Value, and make sure the PDF viewer supports and permits form JavaScript.
Does this script verify that a mobile number is real?
No. It only checks whether the field contains non-whitespace text. Validating a number's format requires additional rules, and confirming that a number is active requires a separate verification service.
What if my checkbox export value is not Yes?
Open the checkbox's Properties > Options in Prepare a form and replace Yes in the script with the listed Export Value. Keep Off as the value used to clear the checkbox.
Will the checkbox update as soon as I type?
The validation script runs when the field value is committed, typically when you move focus to another field. It does not necessarily update with every keystroke.




