Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

required fields with 'read only' on email submit.

Avatar

Level 1

Hi folks.

My hope is to lock fields down to read only when the required fields have had data entered.  These are both text fields and radio buttons.


I currently have my fields set to user entered required on my form and an email submit set to submit as PDF.

attached to my Email submit button is this;

form1.#subform[0].EmailSubmitButton1::postSubmit:form - (JavaScript, client)

for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {

var oFields = xfa.layout.pageContent(nPageCount, "field");

var nNodesLength = oFields.length;

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {

oFields.item(nNodeCount).access = "readOnly";

}

}

Previewing my form;

Clicking submit without entering data to required fields will highlight those fields as expected but it also locks all fields down to read only, not allowing the user to enter data in to the required highlighted fields.

I've done some research but got nowhere fast.  My thinking was, if the fields don't validate then don't run the above script else run the script and submit as PDF.

I've little knowledge of scripting but I am keen to learn and will do.  I don't understand the language but do have an idea of how its structured.   I done a fair bit of basic programming maybe 10 years ago but its vague.

Help is very much appreciated.

4 Replies

Avatar

Level 1

Have I placed this in the wrong section or are replies normally expected to take longer than a few days?

Avatar

Level 7

You need to look into a two button solution. The first button will call the second, hidden submit button if the validation passes, which contains the lockdown code. Otherwise, the second button will not get called, and the form can be edited as before.

Avatar

Level 10

Hi there,

you can actually use a recursive method, if you haven't found anything that suits your request...

*Sorry, modified the function, there was a few errors in the previous function I provided

This will only set all visible fields to readOnly... But even if the fields are readOnly, their events can still be triggered.

To avoid events to trigger even in readOnly, you can set their access property to "nonInteractive" instead of "readOnly"

Hope this help!