6 Replies Latest reply on Aug 5, 2017 3:50 PM by Eli-zabelle

    Lock fields with password

    Eli-zabelle Level 1


      My aim is to lock a number of fields in a form with a password chosen by the person who will administrate the form. It is not a question of high security, it is only to make sure that the fields will not be modified by accidental clics or deletes.

      I was able to accomplish what I wanted with the code suggested in this post : Re: Form Field Security .

      I slightly modified the code for the password to be extracted from another field. Here it is :


      (function () {

      // Get one of the fields in the group

      var f = getField("admin.logo");

      // Determine new readonly state, which

      // is the opposite of the current state

      var readonly = !f.readonly;

      var readonly_desc = readonly ? "deactivate" : "activate";

      // Ask user for password

      var resp = app.response({

      cQuestion: "To " + readonly_desc + " the fields, enter the password:",

      cTitle: "Enter password",

      bPassword: true,

      cLabel: "Password"



      var pw=this.getField("Mot_passe").value;

      switch (resp) {

      case pw: // Your password goes here

      getField("admin").readonly = readonly;

      app.alert("The fields are now " + readonly_desc + "d.", 3);


      case null : // User pressed Cancel button


      default : // Incorrect password

      app.alert("Incorrect password.", 1);






      I applied this code as an action on a checkbox field, it works very well.  Now, I also want the password field to hide if the fields have indeed locked, but to reappear when the fields unlock. So I created a following action with this code :


      var a = this.getField("admin").readonly;

      var b = this.getField("Mot_passe");

      if (a = true) b.display=display.hidden;




      It obeys perfectly to hiding the password field when my group of fields is locked, but will not return it to visible when the fields unlock.

      Please, what do I need to change, if anyone can help?  Thank you!