Custom Validation for Nintex Forms

Document created by eharris04 Employee on May 17, 2016
Version 1Show Document
  • View in full screen mode

This script allows you to add in-depth custom validation power to your Nintex Form.

 

AuthorAaron Labiosa
Long Description

This script and approach is fully compatible with the built in Validation system in Nintex Forms however, this validation will occur prior to the form being evaluated by the built in Forms Validation.

 

//Sets fields in parameter to have a red background.
function showInvalidFields(fields){
for (var i = 0; i < fields.length; i++) {
fields[i].css('background-color', 'red !important'); }
}
//Sets fields in parameter to have a white background.
function resetInvalidFields(fields){
for (var i = 0; i < fields.length; i++) {
fields[i].css('background-color', 'white !important'); }
}
//Pass Client ID configured in Control to this function.
function validateBlankField(nfclientid){
if(!NWF$('#' + nfclientid).val().match(/./)) return false;
return true;
}
//Pass label of out of the box 'Save and Submit' button as parameter.
function submitForm(buttonName){
var validated = true;
var invalidFields = [];
var validFields = [];
//Validating the field 'mytextbox'.
if (!validateBlankField(mytextbox)){
validated = false;
invalidFields.push(NWF$('#' + mytextbox));
}
else{
validFields.push(NWF$('#' + mytextbox));
}
//If form passes validation, submit.
if(validated){
resetInvalidFields(validFields);
NWF$(".nf-disableonsubmit[value="+buttonName+"]").click();
}
//If form fails validation, show invalid fields and prompt.
else{
resetInvalidFields(validFields);
showInvalidFields(invalidFields);
alert('The form is invalid, please correct the highlighted fields, and submit again');
}
}
DependenciesNone
Support Info

Aaron Labiosa - Custom Validation for Nintex Forms

Compatibility

Nintex Forms 2010

Nintex Forms 2013

Nintex Forms Office 365

Platform

SharePoint Server 2010

SharePoint Server 2013

Office 365

Screenshots

Additional Information

To view an example of this in action visit - Custom Validation for Nintex Forms

Nintex Xchange Terms of Use Policy

Nintex makes no warranty or guarantee about the reliability, performance, quality, or functionality of any assets, and any assets you install are therefore provided as is. By downloading this asset, you agree to the terms of use.

1 person found this helpful

Attachments

Outcomes