Skip to main content
Participant
August 2, 2020
Question

Help with script in form

  • August 2, 2020
  • 1 reply
  • 792 views

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()
}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 2, 2020

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

try67
Community Expert
Community Expert
August 2, 2020

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

haley365Author
Participant
August 2, 2020

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()
}