Skip to main content
Nintex Community Menu Bar
Solved

Rule dont apply after update value with javascript

  • March 23, 2015
  • 4 replies
  • 306 views

Forum|alt.badge.img+6

Hi,

 

I use javascript to update a value of a textfield (txtStepID) in my Nintex Form. There are several formatting rules on different controls triggered on this value. Since upgrading to nintex Form from V 2.4.0.0 to 2.5.0.0 the rule is not recognized anymore. I see the value changes due to the step but the rule just don't fire. If I change the field value manually in the textbox the rule is working perfectly.

 

Here is the javascript I use to update my textbox value:

function goNext() {

    var txtStep = NWF$("#" + txtStepID);

    var stepNumber = txtStep.val();

    stepNumber++;

    goStep(stepNumber);

}

function goPrev() {

    var txtStep = NWF$("#" + txtStepID);

    var stepNumber = txtStep.val();

    stepNumber--;

    goStep(stepNumber);

}

function goStep(stepNumber) {

    var txtStep = NWF$("#" + txtStepID);

    txtStep.val(stepNumber);

    txtStep.trigger("change");

}

Best answer by rm

Found it:

...Since V 2.5.x.x Nintex Forms is triggering rule events onblur instead onchange

Therefore I had to change my code as follows:

txtStep.trigger("blur");

4 replies

Forum|alt.badge.img+6
  • Author
  • Answer
  • March 23, 2015

Found it:

...Since V 2.5.x.x Nintex Forms is triggering rule events onblur instead onchange

Therefore I had to change my code as follows:

txtStep.trigger("blur");


Forum|alt.badge.img+3

This perfectly works. Thanks Roman Mellenberger

Cheers

Pramod


Forum|alt.badge.img+11
  • August 14, 2018

May I ask what this script does?

I fail to reproduce the same ...

maybe screenshots (before / after) would provide more information


  • Rookie
  • June 22, 2021

Hey Bimi82,

 

I searched for this issue after noticing rules weren't running after I was updating a field value with JavaScript.  When changing the field value manually on the form the rules did work so I knew something wasn't refreshing/triggering.  My original (and simple 🙂 ) code was:

 

function navButtonClicked(n) {
    NWF$('#' + js_navButtonSelection).val(n);
}

 

As per the instructions here I added the '.trigger("blur");' and it worked great!  The field was being populated with the new value and the rules ran properly (in my case showing/hiding sections).

 

function navButtonClicked(n) {
    NWF$('#' + js_navButtonSelection).val(n);
    NWF$('#' + js_navButtonSelection).trigger("blur");
}