Quantcast
Channel: Adobe Community : Unanswered Discussions - Acrobat
Viewing all articles
Browse latest Browse all 73766

Password protect a change in text field

$
0
0

Ok - I think I need help from a JS whizz! I have one text field in a form that should only be changed by the manager before he sends it to a client. The client then fills in the form, but cannot change this one text field. I imagine a password javascript would be the best way to do this as the manager would only be using Reader.

 

I have found this script from a previous post - it's nearly there, but it doesn't allow the change to happen, it just automatically changes the field to  read-only and back etc. I want to be able to change the text in the field, and then that change is only allowed once the password has been approved. If it needs changing again, you need to put a password in...

 

(function () {

 

    // Get one of the fields in the group
    var f = getField("private.name");

 

    // 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"
    });

 

    switch (resp) {

 

    case "your_password": // Your password goes here
        getField("private").readonly = readonly;
        app.alert("The fields are now " + readonly_desc + "d.", 3);
        break;

 

    case null : // User pressed Cancel button
        break;

 

    default : // Incorrect password
        app.alert("Incorrect password.", 1);
        break;
}

 

})();

 

I'm putting this is in the 'text field properties' 'actions' with the 'mouse up' 'run a javascript' selected. Perhaps a custom validation script may also work - but I'll leave it with the experts! Any help MUCH appreciated!


Viewing all articles
Browse latest Browse all 73766

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>