Copy link to clipboard
Copied
I use adobe forms for my contracts in a roofing business. I need my sales staff to be able to fill in the prices for several options and lock those fields before sending to customer. I will then need the customer to be able to select contract choices, color selection and sign. The only option I'm tech savvy enough to know is to make the price fields "read only" after filling them in. My staff aren't quite advanced enough to do that every time. I'm sure there's a more efficient method. **I have no idea how to create a javascript code, button or bookmark**
Copy link to clipboard
Copied
The basic code to do it is:
this.getField("FieldName").readonly = true;
Copy link to clipboard
Copied
The basic code to do it is:
this.getField("FieldName").readonly = true;
Copy link to clipboard
Copied
Pardon my ignorance, but what do I do with the basic code?
Copy link to clipboard
Copied
You can attach it to the MouseUp event of a button field, for example.
Copy link to clipboard
Copied
OK, so I have 3-6 text fields that sales staff need to fill in, and then be able to lock. Do I add a button field anywhere, add the action to a mouse up, copy the code you provided in a javacript and save? Or do I add a button for each filed to be locked after filling?
Copy link to clipboard
Copied
Depends on how you want it to work... If you want to lock them all with a single click then use a single button.
Just copy and paste that line of code, changing the field name (in quotes) in each one.
Copy link to clipboard
Copied
That worked, thank you!! Now, is there a code that I can add to another button, in case it needs to be unlocked for editing and then locked again?
Copy link to clipboard
Copied
The same code, only replace "true" with "false" (without the quotes!).
Copy link to clipboard
Copied
You have been a tremendous help!! Thank you so much!
Copy link to clipboard
Copied
Thank you so much for this, too - really helped me with my similar use case and I never would have figured it out alone.
Copy link to clipboard
Copied
Hi, I'm an absolute novice at this. Would anyone mind going through it step by step? I need as much help as I can get. Is there a video demonstrating this?
Copy link to clipboard
Copied
Can you describe what exactly you wish to do?
Copy link to clipboard
Copied
I've created an order form with fillable fields. Some of the fields are to be filled in by the sales team such as pricing and customer details and then locked. The other fields are to be kept fillable so that the customer can enter their order or other details.
Copy link to clipboard
Copied
You can use code in a button for example, go to button properties->action tab, select 'Mouse UP' and from dropdown menu select 'Run a Javascript' and click on 'add', now put code inside:
this.getField("Field1").readonly = true;
this.getField("Field2").readonly = true;
this.getField("Field3").readonly = true;
Just copy line to add more fields as needed, and replace field name "Field1","Field2","Field3" with your actual field names.
Copy link to clipboard
Copied
That's worked!
Can you also reverse it and change if necessary?
Copy link to clipboard
Copied
I'm getting it ... woohoo!
Copy link to clipboard
Copied
If you want to switch from the same button then use this line:
this.getField("Field1").readonly = this.getField("Field1").readonly == false ? true : false;
Copy link to clipboard
Copied
So how can I use an if then statement to determine if the field is filled out and if it is, make that field read only, leaving the empty fields open so the customer can complete the form?
if this.getField("Field1") == ""; then thisgetField("Field1").readonly = false; else thisgetField("Field1").readonly = true
Copy link to clipboard
Copied
There is no point doing an if else statement for what you asking, it's enough to make field readonly, only if it's filled out:
if(this.getField("Field1").valueAsString != "")
this.getField("Field1").readonly = true;
Just a piece of advice, what you doing will leave user locked out once field is filled. it would be good idea to create button to reset field in which case you can use this code instead:
this.getField("Field1").readonly = this.getField("Field1").valueAsString == "" ? false : true;
Copy link to clipboard
Copied
TRY67: I used this code in a Document Javascript that is executed by a command button Mouse-up action in a form I created May-2023; it worked perfectly! They updated our AcrobatPro to the latest version and the Javascript won't run now either in the form I created in May or the one I'm currently working on; I've checked for typos and found none. Suggestions?
Copy link to clipboard
Copied
PLEASE DISREGARD my post. I finally got the code to run! Apparently, I had some typos that were difficult to spot--in 105 lines of code. I think I have a MiFi buffering issue also. I apologize for the unnecessary post. I really thought the new upgrade to Acrobat was failing me.