Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

How to lock certain fields in a form?

Community Beginner ,
Mar 12, 2019 Mar 12, 2019

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**

TOPICS
PDF forms
19.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 13, 2019 Mar 13, 2019

The basic code to do it is:

this.getField("FieldName").readonly = true;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2019 Mar 13, 2019

The basic code to do it is:

this.getField("FieldName").readonly = true;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2019 Mar 13, 2019

Pardon my ignorance, but what do I do with the basic code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2019 Mar 13, 2019

You can attach it to the MouseUp event of a button field, for example.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2019 Mar 13, 2019

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2019 Mar 13, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2019 Mar 13, 2019

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2019 Mar 13, 2019

The same code, only replace "true" with "false" (without the quotes!).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2019 Mar 13, 2019

You have been a tremendous help!! Thank you so much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 01, 2020 May 01, 2020

Thank you so much for this, too - really helped me with my similar use case and I never would have figured it out alone. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2021 Sep 16, 2021

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2021 Sep 16, 2021

Can you describe what exactly you wish to do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2021 Sep 16, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2021 Sep 16, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2021 Sep 17, 2021

That's worked! 

Can you also reverse it and change if necessary?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2021 Sep 17, 2021

I'm getting it ... woohoo!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2021 Sep 17, 2021

If you want to switch from the same button then use this line:

this.getField("Field1").readonly = this.getField("Field1").readonly == false ? true : false;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

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 

  

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2022 Mar 04, 2022

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 06, 2023 Sep 06, 2023

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 07, 2023 Sep 07, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines