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

Help with script in form

Community Beginner ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Trying to have an alert pop up only if two conditions are met. The script is running On blur for the text box. First condition is the text box and second is a check box just before it. Right now the message is popping up everytime we tab to the text field regardly if the conditions are met.

 

if ((this.getField("EthnicityOther").value.length == 0) && (this.getField("Other1").value = "on"));
{
app.alert("When Other is selected, please enter a description.")
f.setFocus()
}

TOPICS
Acrobat SDK and JavaScript

Views

84

Likes

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 ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Compare the operators you use in the first and second parts of your if-condition... See any differences?

Likes

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 ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Also, where did you define the "f" variable?

Likes

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 Beginner ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

sorry, I originally defined it...I've made so many changes trying to get it to work that I had removed it. Pretty new to this so been researching code to use.

 

I just tried this and I still get the pop up even if the Other1 field is not checked. Thanks for the help!

 

f = this.getField("EthnicityOther")

if ((this.getField("EthnicityOther").value.length == 0) && (this.getField("Other1").value == "on"));
{
app.alert("When Other is selected, please enter a description.")
f.setFocus()
}

 

Likes

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 ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

- Remove the semi-colon after the if-statement.

- Make sure the export value of the "Other1" field is indeed "on" and not something else (by default it's "Yes").

Likes

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 Beginner ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Well I just wish I had posted this 3 days ago. It's working!! Thanks so much for taking the time to respond.

Likes

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 Beginner ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

LATEST

I did need to change the "on" to "yes".

Likes

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