Copy link to clipboard
Copied
Hello Everyone,
I am trying to write a switch case that uses an if/then statement inside it but I keep getting a Syntax error. I would like certain fields to be outlined green if Joint is selected and they aren't blank, and red if Joint is selected but they are blank. Please let me know what I am doing wrong...
switch(event.value) {case "Joint":
{
if((this.getField("LNS").value !== "") && (this.getField("FNS").value !== ""))
this.getField("LNS").strokeColor=color.green;
this.getField("FNS").strokeColor=color.green;
else if((this.getField("LNS").value == "") && (this.getField("FNS").value == ""))
this.getField("LNS").strokeColor=color.red;
this.getField("FNS").strokeColor=color.red;
};
break;
case "Individual"||"IRA"||"Entity"||"Trust"||"Individual 401K"||"Direct Business 529":
this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;
default:
this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;
}
Thank You Kindly!
Copy link to clipboard
Copied
Try this:
switch(event.value) {
case "Joint":
{
if((this.getField("LNS").value !== "") && (this.getField("FNS").value !== ""))
{
this.getField("LNS").strokeColor=color.green;
this.getField("FNS").strokeColor=color.green;
}
else if((this.getField("LNS").value == "") && (this.getField("FNS").value == ""))
{
this.getField("LNS").strokeColor=color.red;
this.getField("FNS").strokeColor=color.red;
}
};
break;
case "Individual":
case "IRA":
case "Entity":
case "Trust":
case "Individual 401K":
case"Direct Business 529":
this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;
default:
this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;
}
Copy link to clipboard
Copied
Thank you for your reply! Your changes eliminated the syntax error, but when I type something into the fields to test for not blank, the outline remains red, instead of changing to green.
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
In the Account Type Field where Joint may be selected.
Copy link to clipboard
Copied
Yes, but each field has multiple actions. It's very important to say which action you choose, for example "mouse down" or "validate". Only one will work for any given script.
Copy link to clipboard
Copied
I am using the script in the custom validation section
Copy link to clipboard
Copied
Change the selection and it will fires the script.