Having issue with making a script I had written works okay

Avatar

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
lpianwi
Level 2

22-04-2015

Dear All,

I am working on a form, that requires the Signature fields to be "readOnly", unless the two fields fields before it are completed. If the fields are not completed it should show a message, but if these fields are completed no message should show.

I wrote the following script and put on the on enter event of the Signature field, but it does not work well.

var v;

if(form1.Page1.Reviewerssignat.rawValue ==null){

  Reviewerssignat.access="readOnly";

  v=xfa.host.messageBox("Please Complete Supervisor  and Senior Supervisor fields");

}

else if(form1.Page1.Reviewerssignat.rawValue !=null){  

  Reviewerssignat.access="open";

  v=xfa.host.messageBox("");

}

Please can someone out there tell me why it is not working.

Thanks

Tammy

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

23-04-2015

I don't see anything syntactically wrong with this. The problem appears to be that you're checking the field you are entering. Essentially, you're script is saying, "If this field I just entered is empty, then I want to make it read only."

If you're not absolutely set on the idea of making the field read only, you could instead set focus to one of the fields that needs to be filled.

Try this for the enter event of your field that you want to protect when the other two aren't filled.


if (TextField2.isNull) {


  xfa.host.messageBox("You missed a spot");


  xfa.host.setFocus("TextField2");


} else if (TextField3.isNull) {


  xfa.host.messageBox("You missed a spot");


  xfa.host.setFocus("TextField3");


}



(Of course, change the names of TextField2 and 3 to match what your field names, and change the message to be more meaningful. ) Now, this doesn't make that field readOnly, but you can't do anything with it unless those fields are filled. If you only need one or the other to be filled, you could change the logic slightly by adding an if statement that surrounds this to check that they are both empty before proceeding.