Runtime Validation on a input control only fires in the first row of the repeating section of responsive form?


Badge +3

214288_pastedImage_1.png


9 replies

Userlevel 5
Badge +14

Did you resolve this issue at all? 

Badge +3

Bundle & Bundle of Thanks for your such a simple and detailed response. Since, we were very annoyed by the limited and irritated behaviour of responsive forms and not being able to use javascript. When I showed your solution to my Boss he hardly controlled his joy. As soon I impliment your solution, I will mark this as Correct.

Userlevel 5
Badge +14

Excellent! I really do hope that it works. It was a great oppertunity to learn a lot more about the mysteries of the Repeating Section and how validation / validators are used in the new form system. 

I haven't switched over to them yet, but knowing this stuff will hopefully make the change a lot easier. 

Badge +3

Works like Charm....

Userlevel 5
Badge +14

That is very good to hear happy.png 

Glad that it worked! 

Badge +3

Thanx again for your prompt help, I was wondering that you could provide any hint that validations only implemented through ADD RULE button are registered and showing in every added row, however, validations enforce using the Control properties like regular expression are not showing any error message.

Userlevel 5
Badge +14

I can't get deep into it for a while, but I can tell you that by changing only a few lines, it will *kinda* get you to where you're going. 

NWF.FormFiller.Events.RegisterRepeaterRowAdded(function() {
    var currentRow = arguments[0];
    var currentRowValidators = arguments[0].find(".nf-validator-error:not" + "(.nf-hiddenrepeaterrow)");
    var hiddenRow = currentRow.siblings(".nf-repeater-row-hidden");
    var hiddenRowValidators = hiddenRow.find(".nf-validator-error");

    currentRowValidators.each(function(index, currentRowValidator) {

      var validatorFunctionName = currentRowValidator.functionName;
      var parentValidator = hiddenRowValidators.filter(function(index, hiddenRowValidator) {
        return hiddenRowValidator.functionName === validatorFunctionName;
      });

      if (parentValidator.length === 1 && currentRowValidator.display !== parentValidator[0].display) {
        currentRowValidator.display = parentValidator[0].display;

        if (currentRowValidator.style.visibility !== "") {
          currentRowValidator.style.visibility = "";
        }

        var targetValidatingControlContainer = NWF$("#" + currentRowValidator.controltovalidate).closest(".nf-filler-control");
        var controlValidationContainer = targetValidatingControlContainer.find(".nf-validator-error").parent();
        NWF$(currentRowValidator).appendTo(controlValidationContainer);
      }
    });
    registerHighlightControlOnChangeError();
  });

All this does is targets the ".nf-validator-error" class instead of the ".nf_rulesvalidators" class (which is only applied to Custom Rules that have been added via the Add Rule button. 

This actually will place all of your errors below the control, BUT, the catch now is that if you error out the control in one way (let's say, I trigger a Custom Validation Rule), if you then trigger a 'Properties' Rule (like regex), you will render BOTH errors! 

That being said, you might be able to feel your way through it and solve this on your own. If you do, I encourage you to share that here on the forums. If I have some more time in the near future, I will revisit this. 

215117_pastedImage_1.png

*NOTE: My error message is misleading as it's actually .{2,100} or "at least 2 ~ 100 characters long". Whoops! 
Badge +3

How can I enforce regex through custom rules, so there is no need to defined it as Property Rule. I tried using js code ie. (new RegExp(pattern)).exec('string')), but no success. 

Userlevel 5
Badge +14

I recommend checking out my blog about the Validation Rule system and how you can get it to do the things you'd like: Breaking The Rules: A Dive Into The Nintex Forms Rule System  

Ultimately, it'll look something along the lines of:

(function(controlValue) {
  "use strict";

  return controlValue.match(/pineapple/g) !== null;
}({Control:Self}));

Using that validation rule, it will set the control invalid if you type in the word 'pineapple'. 

Reply