Skip to main content

I have written the following code

can anyone tell me where am I going wrong?

NWF$(document).ready(function()

 {  
   var  fromShortcode = NWF$("#" + choiceCode);
   var  toShortcode = NWF$("#" + shortCode);
   var dp1 = fromShortcode.val();

    NWF$('#' + shortCode).change(function()
 {
  alert(dp1);
  alert(toShortcode);
  if (fromShortcode == toShortcode){
 alert("same values in both the field!");
   }
  

});
 
   });

This code will run when the document first loads and not just before the user clicks on any submit button? Is that what you want?


I want to generate an alert  error pop up message as soon as the if condition gets true and not after the user clicks on any submit button.


Have a look at the below article on how to do a real time validation. The script you wrote above would only run once when the form is first loaded and not when the value of your control changes. I still believe Nintex as a product is there for a quick development of business solutions and sometime if you explain to your business users that validation which happens on submit are more easier in terms of development/turn around time /testing etc they might be okay for a different user experience but still giving you the same functionality. You always have the ability to extend Nintex forms by using JS.

Check below for some examples on how you could achieve real time validation.

 

Regards,

Shrini


thank you for article.

the article shows validation when the user does not enter any input in the fields

in my case, I have a drop down list lookup, and if the user choose the same option in both the drop down list then a real time pop up message is to be generated showing 'same values in both the fields' (which is the the condition that I have given I the if statement)

It would be great if u can provide a solution for this as I'm new to nintex.


Hi,

As I mentioned before this is not native to Nintex and the solution given in the above article is more of a hack into Nintex engine and not necessarily the best way to do in Nintex. If you are good in Javascript then you could use that. Instead of using the validation rule its trying to "hack" by passing the object reference back to your JS function and you could evaluate the value and trigger the validation.

If you want to use native Nintex validation then add a rule onto your Lookupcontrol for a validation rule and this will get triggered only when you try saving the form. This is probably the most easiest and native to Nintex. Be sure to use ParseLookup function when you are trying to evaluate any lookupvalue.

Regards,

Shrini


okay thank you!


Hi, have you find out the solution
I also have same issue if you know please help me . I'm new to the nintex

Reply