Nintex Forms – Basic Validation

This post will be the first in a series of articles that I have planned out that will cover Nintex Form customizations in detail. I’ve been working really closely with the Forms product and looking into how heavily we can customize a Nintex Form and the ways we can leverage javascript to do some really neat things. I’d like to share some of my findings.

The first piece I thought I’d cover is some validation basics. Specifically, how do I validate a required field on my Nintex Form.

Well, we have a couple of options, so let’s go into detail on each one.

  • Option 1: Use the default required field validator in a Nintex Form
  • Option 2: Wire up your own custom validator

Option 1
This option is pretty straight forward. If you configure your list or content type column so that the field is required, Nintex will automatically do the validation for you. Let’s configure our Title column so that it’s required:

Ok and now here’s what happens when we Preview the Nintex Form:

And we can take this a step further by customizing the error message that is displayed when required field validation fails. This is done by supplying a value for the Required error message field:

So now we end up with:

Option 2
Now what do we do if we need to do some custom validation of our own? How do we wire that up? Let’s walk through that.

First thing we need to do is TURN OFF the required field setting for this particular field. If we don’t do this, our validation will overlap. In theory, if you’re going to wire a custom validator, you can do all the validation you need in that function, you shouldn’t need both.

Alright, so now let’s wire up our custom validator on the Nintex Form. Set the Use custom validation property to Yes and specify the name of the custom validator along with the message you want to show if the validation fails:

Finally, we need to configure our javascript function to perform our validation. In the Ribbon, click on the Settings link. The very last section should be labelled Custom JavaScript, expand it. You’ll want to insert the following javascript which sets up our ValidateTitle function.

1
2
3
4
5
6
function ValidateTitle(source, arguments) {
    arguments.IsValid = true;
    if (arguments.Value == "") {
        arguments.IsValid = false;
    }
}

Save and test your form, behaviour should be almost identical to Option 1, however, we now have a function at our disposal where we can program any logic we’d like. If you look carefully, you may notice that the red asterisk is missing. You’ll want to add that back yourself if you’d like to have it displayed.

If you have any questions, let me know! In my next post in this series, we’ll cover some of the more advanced validators available within Nintex Forms.

,

6 Responses to “Nintex Forms – Basic Validation”

  1. Edwina K. Baird February 4, 2013 at 6:23 am #

    Regarding how to make a custom validation attribute, since I’m not sure what language you’re using, assuming you’re using MVC3, or if you even need this info anymore 4 months after you asked, I’m going to simply leave these links for reference.

  2. shereen February 4, 2013 at 9:55 am #

    Hi Edwina,

    I’m not sure what links you’re referring to? This is a Nintex Forms application. So not MVC3. I don’t recall posting any question about this, I’m new to Nintex and have just recently started working with it.

  3. Shereen Qumsieh September 11, 2014 at 4:28 am #

    I know, unfortunately my site as hacked and my content deleted, i had backups of the DB but not the wordpress images folder. lesson learned the hard way. so sorry but i’ve just not had time to go through these and redo the images.

  4. Jon October 6, 2016 at 2:36 am #

    Hi Shereen,

    Thanks for this. Just wondering if you can help a bit more. I have set the validation but want to disable it if the field is hidden. is there something I can add to the custom Javascript?

Trackbacks/Pingbacks

  1. Nintex Forms – Basic Validation | SharePoint Development & Ops | ARB Security Solutions - SharePoint Security Integrators - January 15, 2013

    […] Post From SharePoint Development – Google Blog Search: This post will be the first in a series of articles that I have planned out that will cover […]

Leave a Reply