Skip to main content
Cheena12
Inspiring
June 6, 2018
Answered

How to fix my validation script

  • June 6, 2018
  • 1 reply
  • 1177 views

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!

This topic has been closed for replies.
Correct answer try67

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?

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 6, 2018

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?

Cheena12
Cheena12Author
Inspiring
June 6, 2018

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!

try67
Community Expert
Community Expert
June 6, 2018

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