How to fix my validation script

Explorer ,
Jun 06, 2018

Copy link to clipboard

Copied

I have the following validation script that is giving me a syntax error in line 2.

if (event.value == "Nurse" || event.value == "Psychiatrist") {

this.getField("ClassBE").display = display.visible;   

}

else {

this.getField("ClassAE").display = display.visible;

}

My desired outcome is to have a specific field display (ClassBE or Class AE) depending on what is entered in this field. So if Nurse or Psychiatrist is selected, then the ClassBE field displays. If anything other than those two are chosen, ClassAE should be displayed.

Can someone please help me determine why I am getting this syntax error?

Thank you!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

The code you posted is fine. Are you sure that's the exact code you're using? Did you copy & paste it, or re-type it?

Also, what application are you using to edit the code?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

139

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

How to fix my validation script

Explorer ,
Jun 06, 2018

Copy link to clipboard

Copied

I have the following validation script that is giving me a syntax error in line 2.

if (event.value == "Nurse" || event.value == "Psychiatrist") {

this.getField("ClassBE").display = display.visible;   

}

else {

this.getField("ClassAE").display = display.visible;

}

My desired outcome is to have a specific field display (ClassBE or Class AE) depending on what is entered in this field. So if Nurse or Psychiatrist is selected, then the ClassBE field displays. If anything other than those two are chosen, ClassAE should be displayed.

Can someone please help me determine why I am getting this syntax error?

Thank you!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

The code you posted is fine. Are you sure that's the exact code you're using? Did you copy & paste it, or re-type it?

Also, what application are you using to edit the code?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

140

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
Jun 06, 2018 0
Most Valuable Participant ,
Jun 06, 2018

Copy link to clipboard

Copied

The code you posted is fine. Are you sure that's the exact code you're using? Did you copy & paste it, or re-type it?

Also, what application are you using to edit the code?

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
Reply
Loading...
Jun 06, 2018 1
Explorer ,
Jun 06, 2018

Copy link to clipboard

Copied

I had provided a modified version of my code for simplicity's sake since it was so convoluted and ugly. Now I understand why the code was not working: the text I was referencing had parens which was throwing the code off. For example, "Nurse (011)". Once I took off the parenthesis, no more syntax error.

Thank you for making my error apparent!

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
Reply
Loading...
Jun 06, 2018 0
Most Valuable Participant ,
Jun 06, 2018

Copy link to clipboard

Copied

If the parentheses were inside double-quotes that should not be a problem... Anyway, glad to hear you were able to sort it out.

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
Reply
Loading...
Jun 06, 2018 0
Explorer ,
Jun 06, 2018

Copy link to clipboard

Copied

It looked like this:

if (event.value == "Ambulatory Care Nurse (F014)" || event.value == "Charge Nurse (F012)" || ...

You're saying that should not have caused a problem?

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
Reply
Loading...
Jun 06, 2018 0
Most Valuable Participant ,
Jun 06, 2018

Copy link to clipboard

Copied

Yes, that is fine, but post your full code, please.

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
Reply
Loading...
Jun 06, 2018 0
Explorer ,
Jun 06, 2018

Copy link to clipboard

Copied

if (event.value == "Ambulatory Care Nurse F014" || event.value == "Charge Nurse F012" || event.value == "Clinical Nurse F011" || event.value == "Correctional Health Nurse F018"|| event.value == "Critical Care Nurse F022" || event.value == "Infusion Nurse F025"|| event.value == "Licensed Vocational Nurse F020" || event.value == "Licensed Vocational Nurse - Unclassified B155"|| event.value == "Long Term Care Nurse F027" || event.value == "Medical Surgical Nurse F031"|| event.value == "Perioperative Nurse F034" || event.value == "Psychiatric Nurse F037"|| event.value == "Public Health Nurse - Unclassified B100" || event.value == "Supervising Child Psychiatrist F128") {

    this.getField("SalaryStepsClassBE").display = display.visible;

    this.getField("SalaryStepsClassAE").display = display.hidden;

}

else {

    this.getField("SalaryStepsClassAE").display = display.visible;

    this.getField("SalaryStepsClassBE").display = display.hidden;

}

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
Reply
Loading...
Jun 06, 2018 0
try67 LATEST
Most Valuable Participant ,
Jun 06, 2018

Copy link to clipboard

Copied

This code is fine... You can add the parentheses (as long as they are inside the quotes!) and it should remain fine.

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
Reply
Loading...
Jun 06, 2018 0