AEM Form Designer Check whole form for Empty Fields / Validation check | Community
Skip to main content
rakeshk21205956
Level 3
October 3, 2021
Solved

AEM Form Designer Check whole form for Empty Fields / Validation check

  • October 3, 2021
  • 1 reply
  • 2071 views

Sir / Madam,

 

I have made a form in AEM Designer in which i have all type of fields with subforms postioned / flowed ....

i want to add a button at the end to check if all the fields are filled , and if filled then according to the validations.

I found the below script on this forum.. it works fine.. but it doesnot work for Radio button & check boxes & for default value fields......

1. for Radio button instead of checking the Radio Group it checks each options inside the Radio group for emptiness

2. for checkbox  if i have 20 it checks each of them but i want .....  say if out  of 20 only 5 should be checked rest can be left blank

3. for defaultValue this script not working... it doesnot check the text field or any other field which has default value in it.... i want if any field has default value it should be shown in the error 

Here is the script: 

 

 

var EmptyFields= new Array(); 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++) { if ((oFields.item(nNodeCount).ui.oneOfChild.className != "button") && (oFields.item(nNodeCount).rawValue == null ||oFields.item(nNodeCount).rawValue == "")) { EmptyFields.push(oFields.item(nNodeCount).name); } } } if (EmptyFields.length>0) { app.alert("Following fields are required. Please, fill in the following field(s):\n\n" + EmptyFields.join("\n")); } else {app.alert("All Fields have been filled!!!");}

 

 

@radzmar  

@kosta_prokopiu1 

@chitramadan 

@lavanya_pejjayi 

@pulkit_jain_ 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kosta_Prokopiu1

2. Check boxes are individual items. If you have such a specialized requirement you need to script it. 

3. You cannot treat fields with default values as empty. Why would you provide a default value in the first place when it should not be used? Use the tooltips or labels to point the user to the use of that field if this is what you intend to do. The default value is written into the data model, I have no means of comparing your "default value" with the current field content. 

1 reply

Kosta_Prokopiu1
Adobe Employee
Adobe Employee
October 5, 2021
rakeshk21205956
Level 3
October 5, 2021

yes sir, i saw but the problem still there:

 

1. you have solved the radio button issue.

2. Check box issue : if i have 20 checkbox and want to set only 5 to be mandatory rest 15 can be blank - 

3. default value  , if default value is set to the fields this script ignores them., i want default value to be treated as empty fields.

 

thanks 

Kosta_Prokopiu1
Adobe Employee
Kosta_Prokopiu1Adobe EmployeeAccepted solution
Adobe Employee
October 5, 2021

2. Check boxes are individual items. If you have such a specialized requirement you need to script it. 

3. You cannot treat fields with default values as empty. Why would you provide a default value in the first place when it should not be used? Use the tooltips or labels to point the user to the use of that field if this is what you intend to do. The default value is written into the data model, I have no means of comparing your "default value" with the current field content.