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()
}
Copy link to clipboard
Copied
Compare the operators you use in the first and second parts of your if-condition... See any differences?
Copy link to clipboard
Copied
Also, where did you define the "f" variable?
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()
}
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").
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.
Copy link to clipboard
Copied
I did need to change the "on" to "yes".