0

I have a checkbox, a dropdown, and a signature field.

If the box is checked or the dropdown is set to a certain value, the signature field needs to be Required. If the checkbox is unchecked and the dropbox is not set to that certain value, then the signature field needs to be not required.

It appears the checkbox is changing the requirement value every time it is checked or unchecked, regardless of the value of the dropdown. It is triggering at the correct time, just not setting the requirement value correctly. The alerts are showing correctly what the document should be doing, but the requirement value is changing incorrectly.

Can anyone see what is wrong with this code that is giving me this weird behavior?

function ReqSignature()
{
 var ReorderReason = this.getField('ReorderReason');
 var Signature = this.getField('Signature1');
 var ChangedAddress = this.getField('ChangedAddress');

 if (ReorderReason.value == 'New Card' || ChangedAddress.value == 'Yes')
 {
  app.alert('In condition 1');
  Signature.required = (event.target.value!=='Off');
  app.alert('Set to Req');
 }
 else if (ReorderReason.value != 'New Card' && ChangedAddress.value != 'Yes')
 {
  app.alert('In condition 2');
  Signature.required = (event.target.value=='Off');
  app.alert('Set to not Req');
 }

}
G..
  • 1
  • 2
  • Looks to me like when ChangedAddress goes from Yes to No, regardless of what ReorderReason is, it sets it to the opposite of what the alerts say it should be. So it's getting into the correct section, but doing the wrong thing. So I must be misunderstanding how the code is being used. – G.. Feb 21 '18 at 19:01
  • How is the function getting called and from what field, if it's being called from a field. "event" is generally used from inside one of the field events or actions. – joelgeraci Feb 21 '18 at 20:32
  • It's being called on blur from both of the fields that are subject to change. – G.. Feb 22 '18 at 13:47

0 Answers0