Expand my Community achievements bar.

SOLVED

if/else scripts

Avatar

Level 2

I am trying to make this where if this checkbox is checked then it checks to see if SSN has a correct number in it or it returns an error.

This is what i have in there now.

if (xfa.resolveNode("this").rawValue == "1")

{

     SSN.mandatory = "error";

     app.alert("Please fill in the Dependent SSN portion of this form.");    

}

else

{

     SSN.mandatory = "disabled";

     }

This works all too well. if they do have a number in the field, it still gives the error.  I need that not to happen.

Also, I need another checkbox to do the same thing but also add in if "age" is equal to or greater than 1 = true, if not then return an error.

any and all help would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 5

It depends on where you are running your script from and which event. If its on the check box then you will also need to check for the SSN before displaying your message, as at the moment it just fires the error when the checkbox is checked - nothing else. So something like

if ( this.rawValue == "1" && SSN.isNull )

{

... handle error

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

It depends on where you are running your script from and which event. If its on the check box then you will also need to check for the SSN before displaying your message, as at the moment it just fires the error when the checkbox is checked - nothing else. So something like

if ( this.rawValue == "1" && SSN.isNull )

{

... handle error

}

Avatar

Level 2

I am using it in the Change event of the checkbox.

And that worked Perfect!  I knew i was missing something small. 

what about the adding the =<1 ?