• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Validation script for a text field to be required based on dropdown selection not working!

New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Hi, I am working in Acrobat DC and created a terms and conditions form used for clients to sign and return.  One of the dropdown selections allow the client to either "Authorize" or "Not Authorized" us to use their credit card.  There are several text fields, whereby the default is "Not Required", however if they select "Authorize", I want those text fields to change to "Required".  I have tried custom validation scripts recommended in other posts, but when selecting the "Authorize" option in the dropdown, those text fields still DO NOT change to required.  The current script I am using is in the dropdown field:

 

this.getField("Name of text field").required = (event.value=="OTHER");

 

I have also tried similar script in each of the text fields, but to no avail.

 

I also tried to use this.calculateNow(); in the document level javascript, but again, doesn't change text fields to required after the dropdown selection.

 

Summary, any of the custom validation scripts I have used don't change text fields from Not Required to Required when completing the form.

 

Can anyone help?

 

Thank you,

 

Bob

TOPICS
Acrobat SDK and JavaScript

Views

812

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Why does you compare event.value with "OTHER" ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Sorry, my laziness, that was the sample code.  Actual code for the dropdown is (trying to get text field "Text4" to be required)

 

this.getField("Text4").required = (event.value=="Authorize");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

You can use this code as custom calculation script of dropdown field:

this.getField("Name of text field1").required = event.target.value == "Authorize" ? true : false;
this.getField("Name of text field2").required = event.target.value == "Authorize" ? true : false;

Add more field if you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Hi Nesa, thank you so much for replying!  I just tried above and same result...when selecting "Authorize" from the dropdown, Text4 field still does not change to required.  Ugh!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Did you change field name to Text4?

If you just want to change one field in this case "Text4" field use this code as custom calculation script of your dropdown field:

this.getField("Text4").required = event.target.value == "Authorize" ? true : false;

Also check that Authorize is spelled correctly and in drop down options tick 'commit selected value immediately'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Yes, I had created a simple form to test this...text field is "Text4", I havve "commit selected value immediately" checked...everything is spelled correctly.  Not changing Text4 to required still.  Very frustrating as this seems to be a simple thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Can you share this form?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Hopefully this link works.  Again, this was created as a simple test form (not the actual form that I will ultimately be using).  The hope was to get this to work on a test form, then apply to the actual (which has proprietary info in it).

 

DropDown9 - simple dropdown with "Authorize" or "Not Authorized" as options

Text3 - text box (required)

Text4 - text box (not required) - this is the one I am trying to have changed to required if "Authorize" selected in DropDown9

Signature5 - signature box (required)

 

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:39c67080-5422-4d61-85c1-b669ceadd37...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

It's working for me, here is your file with code in it.

test it:

https://drive.google.com/uc?export=download&id=1ttmU-J2xmivwXR8lNf26ySyatuZlQ8Qt 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Hi again Nesa, thank you again!!  There are no errors, so in that sense "it is working".  However (hopefully you can see in below), the form still allows signing and sending without requiring Text4 to be completed.  I just tested it again...

robertd66522140_0-1602519001897.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

The property required will not work when you use Adobe Sign.

For Adobe Sign use a Adobe Sign form and the features of Adobe Sign.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Thank you Bernd!  Are you aware of script that will work when using Adobe sign?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

LATEST

Try the forum for Adobe Sign.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

At validation of the dropdown use this:

this.getField("Text4").required = event.value == "Authorize" ? true : false;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines