cancel
Showing results for 
Search instead for 
Did you mean: 
mtrividic
Nintex Newbie

Custom validation function not fired on repeating section

Jump to solution

Hi everybody,

After trying to resolve my problem with the Nintex support, they suggest to me to create this question on dev talk.

In fact, the problem concern JS on forms so they can't help me.

My problem is the custom validation function in a textarea or other placed in a repeating section.

This custom validation function is only fired for the first line of repeater, after that when to add more lines, custom validation function is never called.

This function is just a call to my method JS included to the form, it permit to replace commas by dots to prevent bad calculation of amount by Nintex (decimal separator VS thousand separator).

Anyone know how can I work around my problem with JS or not... I've already try to use validation rules, regex but it doesn't work when the textarea is define as a double value instead of string by default.

Thank you a lot for your time

Best regards.

0 Kudos
Reply
8 Replies
mlauer
Nintex Newbie

Re: Custom validation function not fired on repeating section

Jump to solution

You can use Nintex Forms RepeaterRowAdded event to bind an event handler to the "change" JavaScript event of form fields.

See JavaScript events in Nintex Forms

Reply
Highlighted
sojanm
Nintex Newbie

Re: Custom validation function not fired on repeating section

Jump to solution

Hi Max,

If you are just calling a function , you can just use a calculated control and hide it under some control, don't make visible false for the calculated control. Pass the row number to the function.

Reply
Automation Master
Automation Master

Re: Custom validation function not fired on repeating section

Jump to solution

from my point of view this is definitely a bug!

what I've investigated it works like this

  • custom validation function is correctly applied to the controls in all the repeater rows that are (by default) created when the form is instantiated. that means, in new mode if you set minimum number of rows to 1, custom validation function is applied just to that first row. if you set minimum number of rows to eg. 5, custom validation function is applied to all these 5 rows.
    in edit mode, custom validation function is correctly applied to as many row as there were previously submitted.
  • custom validation function is invoked for controls in new repeater row while the row is being constructed. however it is not invoked on control's content change event.
    when I dig a bit deeper into problem, I could see Validator object is being prepared in the background, but finally it's not attached (correctly) to the control in new row resp. it gets somehow lost. it's just saved in some kind of global validators cache. likewise, respective onchange trigger is not attached to the control that would fire validation.

for single line text control I found following workaround myself

(note, the code only causes to fire custom validation on control's content change event. it doesn't prevent the validation to be fired during new row construction)

NWF.FormFiller.Events.RegisterRepeaterRowAdded (function () { 
           var repeaterRow = NWF$(arguments[0][0]);
           repeaterRow.find(".nf-associated-control")[0].onchange=NWF$(repeaterRow.siblings()[1]).find(".nf-associated-control")[0].onchange;
           repeaterRow.find(".nf-associated-control")[0].Validators =
                      NWF$(Page_Validators).filter(function(idx,elem){
                      return elem.controltovalidate==repeaterRow.find('.nf-associated-control')[0].id;
           })
});
Reply
mtrividic
Nintex Newbie

Re: Custom validation function not fired on repeating section

Jump to solution

Hi,

Thank you for this great response,  I will try this as soon as possible.

I will return back to you to inform about the successfully method.

Have a good day !

Reply
charlesralston
Nintex Newbie

Re: Custom validation function not fired on repeating section

Jump to solution

Hi

I was looking at your post, trying to solve a similar issue I am having on a form and had a few questions.  In your work-around, you are doing a find for ".nf-associated-control".  Is this a CSS class that you have assigned to the control that you are monitoring for a change?  I have a form with a repeating section that is going to be used for scheduling meetings.  The form has a start time and end time date/time field and what I am trying to do is set the date of the end time to be the same as the date entered in the start time.  This works on the first row (as you mentioned), but is not working on any new rows.  I tried adding the function you posted, but it didn't seem to work.  Any guidance or help you can provide would be appreciated.

Thanks,

Charles Ralston

Reply
Automation Master
Automation Master

Re: Custom validation function not fired on repeating section

Jump to solution

you are doing a find for ".nf-associated-control".  Is this a CSS class that you have assigned to the control that you are monitoring for a change?

no, it's nintex' internal class.

try to explore DOM how/where it is assigned.

This works on the first row (as you mentioned), but is not working on any new rows.  I tried adding the function you posted, but it didn't seem to work.

this topic and my post deals with validations, setting/copying a control's value is something different.

for setting a date control with repeating section I would suggest to go through following thread Having fun with Date / Time in Nintex Forms 

View solution in original post

Reply
charlesralston
Nintex Newbie

Re: Custom validation function not fired on repeating section

Jump to solution

Thanks ‌.  The link actually got me on the right track and I was able to get the correct javascript code to make this work as I was hoping!  Appreciate the guidance and assistance.

Reply
Automation Master
Automation Master

Re: Custom validation function not fired on repeating section

Jump to solution

Maxime TRIVIDIC, Did you get this resolved?

0 Kudos
Reply