We are running SharePoint 2013 with Nintex Forms: 220.127.116.11
I have an issue where custom validation with the "Custom Validation Function" on a Single line of Text control fires when I do not want it to. Oftentimes, it also fires more than once.
Fig. 1 Screenshot of control setting
When the function runs
- it usually runs twice
- it always runs the first time after I blur out of the input field with the custom validation function
- it sometimes runs after clicking Submit
I've tried running the validation in Form Edit Mode as well as from a published version of the form, but the same outcomes occur regardless.
I've also tried adding () after validateCompanyNameUniqueness (e.g. validateCompanyNameUniqueness() ) which prevents the function from being called more than once, but then the function does not receive the Nintex arguments object with .isValid key. Side question: How do I explicitly pass in the implicit arguments into my validation function from this control setting?
If you want to see the validation code, it's below; however, I am almost positive it is not the custom code that is causing the function to be called at weird times because this happens across different forms and validation functions on our sites.
var isNewMode = document.location.pathname.indexOf("/NewForm.aspx") > -1;
// config for Fuse fuzzy match js library
Solved! Go to Solution.
Why is custom js validation function being called twice?
it's because nintex attaches 2 onchange handlers to a control being custom validated.
I'm not sure why it is so, but it sounds to me to be a bug.
I can reproduce it in newest version 18.104.22.168. however this is not the case in older 22.214.171.124
I would say it's worth of reporting it to Nintex Support
I've also tried adding () after validateCompanyNameUniqueness (e.g. validateCompanyNameUniqueness() ) which prevents the function from being called more than once
if you checked developer console, you would see it throws an error.
this is not correct usage.
How do I explicitly pass in the implicit arguments into my validation function from this control setting?
you can not do that.
custom validation function is invoked dynamically through eval() call with two hardcoded parameters passed in.