Expand my Community achievements bar.

SOLVED

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

Avatar

Level 3

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_ 

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee

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. 

View solution in original post

4 Replies

Avatar

Level 3

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 

Avatar

Correct answer by
Employee

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. 

Avatar

Level 3

ok sir,

got your point regarding the default value of text fields, but what about the dropdown and listboxes ,  i want -select- Option to be default value, and if user not select any other option it should be treated as empty