These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Validation and repeating instances - tables and subforms

R_Boyd
Registered: Nov 1 2007
Posts: 151

After much wailing and gnashing of teeth, we finally managed to get to the point where we have a script that will identify a blank mandatory field, change its colour, change the icon from a * to ! and then populate a text field with the fields with an error.

Yay!

Then we add another instance of the subform and the script doesn't work because its specific to that given row / subform.

Boo.

What I think I need to do is amend the script so that it looks at all instances of a row or subform and then validates them.

How do I go about doing this? Is it something to do with xfa.resolveNode or using [*] . I have tried these but my scripting is not particulary strong so I may be using the wrong syntax or approach.

Your help as ever is appreciated.

suewhitehead
Registered: Jun 3 2008
Posts: 232
This may help. It is from a forum post that I made when I was looking for a similar solution. I was trying to make the RemoveLineBtn button on a repeating subform invisible, as you can see.

"I finally got it in FormCalc. It is
xfa.form.form1.P1.ItemSet[*].RemoveLineBtn.presence = "invisible"

I never have been able to get the Javascript version, though. "
garath
Registered: Mar 24 2009
Posts: 49
The script should look like:
var rowsLength= _Row1.instances.count ; //where Row1 is your row in table or subform. The "_" is important.
//
for(var i=0;i
R_Boyd
Registered: Nov 1 2007
Posts: 151
Thanks for your responses but this isn't quite what I'm looking for.

What I am trying to do is check a set of fields within a row or subform for each instance of that subform so that if Row/Instance 1 is fine but Row/Instance 2 is missing a field then this will be indicated to the user by highlighting the offending field(s) and populating a text area with the name of the fields that have failed validation.

Here is the script I have used for 'Check Part 2' which is a table. If someone has clicked to say that the applicant is a member of staff than they must put a value in the Staff Number field.

var errorVar = "" if   (form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRStaff.rawValue == 1&& (form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.rawValue == null||  form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.rawValue == "")){form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.fillColor = "250,200,200";errorVar = errorVar + "\n \t- Fast Streamer cost centre code-";}else{form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.fillColor = "242,245,247";}  if (  form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRStaff.rawValue == 1&& (form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.rawValue == null ||  form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.rawValue == "")){form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.fillColor = "250,200,200";errorVar = "\n \t-xxxxx Mismatch error message";}else{form1.Part2.part2FlowContainer.questionContainer2.Subform2.Table1.Row1.BERRSENum.fillColor = "242,245,247";} // Addition of the first line of the error message (Please note ...) to the errorVar variable// Render errorMessages subform if the errorVar variable is not null if (errorVar != ""){errorVar = "! Please note: The following fields were highlighted as missing or incorrect:" + errorVar;form1.Part2.part2FlowContainer.questionContainer2.errorMessages.errorMessages.rawValue = errorVar;form1.Part2.part2FlowContainer.questionContainer2.errorMessages.errorMessages.presence = "visible";}else{form1.Part2.part2FlowContainer.questionContainer2.errorMessages.errorMessages.presence = "hidden";}

Part 3 is a form to fill in the successful applicant details. It has three sections that are context sensitive. Users can add additional instances of this subform.

It's a longer script due to the number of mandatory fields and scenarios that have to be covered so here is a sample.

var errorVar = ""  if (  form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullName.rawValue == null|| form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullName.rawValue == ""){form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullName.fillColor = "250,200,200";form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullNameMarker.rawValue = "!"errorVar = "\n \t- Full name";}else{form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullName.fillColor = "229,234,239";form1.Part3.introductionSection.part3flowContainer.part3a.fullName.fullNameMarker.rawValue = "*";} // Addition of the first line of the error message (Please note ...) to the errorVar variable// Render errorMessages subform if the errorVar variable is not null//if (errorVar != null || errorVar != "")if (errorVar != ""){errorVar = "! Please note: The following fields were highlighted as missing or incorrect:" + errorVar;//xfa.host.setFocus("form1.flowSubForm.Page1.part1FlowContainer.questionContainer.recruitMan.nameRecruitMan");form1.Part3.introductionSection.part3flowContainer.part3a.errorMessages.errorMessages.rawValue = errorVar;form1.Part3.introductionSection.part3flowContainer.part3a.errorMessages.presence = "visible";}else{form1.Part3.introductionSection.part3flowContainer.part3a.errorMessages.presence = "hidden";}