1 Reply Latest reply on Apr 23, 2015 12:10 PM by jasotastic81

    Having issue with making a script I had written works okay

    lpianwi

      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

        • 1. Re: Having issue with making a script I had written works okay
          jasotastic81 Level 3

          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.