Need help with code that checkes to make sure all required fields are not "0"
I have a javascript code that I created to check for any fields that are required and have a value of "0" to display an alert, which I made for Acrobat form, I need help converting for AEM, and was hoping someone could help me out?
Here is the code I have:
pmp.Page9.#subform[2].check_form::mouseDown - (JavaScript, client)
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("**The first number indicates the Objective number** \n \n You have a zero rating in the Measuring Success section for the following ratings:\n\n" + emptyFields.join("\n"));
}
else
{
app.alert("All fields have been filled out successfully, and no errors were found.", 3)
}I was hoping to get some pointers to help me learn.
All of the drop down fields default value is "0", and I have another script, that I am trying to work on as well to convert, which will make the fields I need set to required, if this field in not empty, since we have 13 sets of questions, which don't all get used all of the time.
So here is the code that I have for the field that sets the required presence:
if(pmp.Page1.object1.kpi1.value == null)
{// Field is empty, other fields not required
pmp.Page1.object1.Table1.Row1.ratingbox1_1.presence = "optional";
pmp.Page1.object1.Table1.Row1.ratingbox1_2.presence = "optional";
pmp.Page1.object1.Table1.Row1.ratingbox1_3.presence = "optional";
pmp.Page1.object1.Table1.Row1.ratingbox1_4.presence = "optional";
pmp.Page1.object1.Table1.Row1.ratingbox1_5.presence = "optional";
}
else
{// Field has data, other feilds required
pmp.Page1.object1.Table1.Row1.ratingbox1_1.presence = "required";
pmp.Page1.object1.Table1.Row1.ratingbox1_2.presence = "required";
pmp.Page1.object1.Table1.Row1.ratingbox1_3.presence = "required";
pmp.Page1.object1.Table1.Row1.ratingbox1_4.presence = "required";
pmp.Page1.object1.Table1.Row1.ratingbox1_5.presence = "required";
}
I have been trying to modify it for AEM, but still no luck with the 2nd piece of code either.
Can someone please help me out?
