Skip to main content
davidt36293775
Participant
December 11, 2017
Question

Need help validating a field entry after using java script

  • December 11, 2017
  • 1 reply
  • 248 views

Good evening, everyone!

Here's the problem.  I have a numeric field which is filled in by the end user.  After that question, the user is asked to select from a drop down menu of text options.  If the selected text option is "Text A" then the numeric field should be validated to a max value of 12.  If "Text A" is NOT selected then the max value of the field is 20.  I'm trying to use the following script to validate an if/then statement.

The script works well when the text is selected first, however, if the numeric value is filled first then the script does not validate the numeric field to 12 unless the user goes back into the box..  Is there a way to have the numeric field automatically correct to 12 if the value is greater than 12 if Text A is selected after the numeric field is populated?  Any help is appreciated!

// Custom Validate script of a numeric text field

(function () {

     // Get the value of the TextChoices field, as a string

     var sTextChoices = getField("TextChoices").valueAsString;

     // Alter this field's value if necessary

     if (+event.value > 12 && sTextChoices === "Text1") {

         event.value = 12;

     }

})();

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 11, 2017

You need to write a separate validation script for the "TextChoices" text

field, where it changes the value of this field if the same conditions are

met.

On 11 December 2017 at 02:01, davidt36293775 <forums_noreply@adobe.com>