Skip to main content
Participant
September 5, 2023
Question

form

  • September 5, 2023
  • 2 replies
  • 1255 views

Hello, I want to create a field in which only "0" or "5" can be typed. I would appreciate your help

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
September 5, 2023

You should use a drop-down field for that.

Participant
September 6, 2023

TNX u all

Inspiring
September 5, 2023
var field = this.getField("myField");
field.setAction("Validate", "if(event.value != 0 && event.value != 5) {app.alert('Only 0 or 5 are allowed'); event.rc = false;}");

In this example, myField is the name of the field you want to validate. The setAction method is used to set a validation action for the field. The validation action is a JavaScript function that checks if the value entered in the field is not 0 and not 5. If the value is not valid, an alert message is displayed and the value is not accepted (event.rc = false).

You can add this code to the JavaScript section of your PDF form. You can access this section by opening the form in Adobe Acrobat, selecting Tools > Prepare Form, and then clicking on the More button and selecting JavaScript.

 

try67
Community Expert
Community Expert
September 5, 2023

You might want to allow the user to also clear the field...