Those following this post on Nintex connect, know that I have been struggling to set client validation on controls in the form that our end-users have to submit which are required fields. Issue with description can be found in this NintexConnect post.
Text/ field validation with button click in #nintexforms for #office365

Support team was quite helpful as always but this time, it was a little more difficult to troubleshoot to get this validation to work.

I used several references and they are listed at the end of the post. But long story short,

  • Validation rules with Regex did NOT help me with anything or the desired effect that my client was  asking for.
  • I had to setup a On-Click event in on of the buttons that forward the screen to the next screen for selection of systems and submitting request(Save & submit button in the end)
  • Screen 2 had a ‘Next’ Button. On click of the next button I captured the values of the controls in the form that were REQUIRED.
  • If they were deemed empty, then, user gets alerted about filling out REQUIRED controls in the form and the focus  gets set to the control that is empty.
  • Control settings for the single line text box store client id in JavaScript variable to YES, Client ID JavaScript variable name as varFirstNameID
    validation2
  • My controls that were required were
    • First Name
    • Last Name
    • Middle Initial
    • Department  or School(Drop down list, which is filters another cascaded drop-down list in the form for Manager of the department)
    • Manager

      As long as the fields values are entered, the form refuses to go to the next step for selection of systems, prompting users to fill out the required inputs.

  • This is the script that does the validation part and it is self-explanatory
    //This is the function that moves the screen from one form to another for submission
    function goStep(stepNumber)
    {
    var hiddenTxtBoxStep= NWF$(“#”+hiddenTxtBoxStepID);
    hiddenTxtBoxStep.val(stepNumber);
    NWF.FormFiller.Functions.ProcessOnChange (hiddenTxtBoxStep);
    //alert(stepNumber);
    if(stepNumber==”3″) ValidateControls();
    }
    //Function that is used to validate the REQUIRED controls. If they are empty then the form submission stops and doesnt progress to the next page for selecting systems.
    function ValidateControls(stepNumber)
    {
    //default value used to capture whether the control was empty or has value
    var validationError=false; 
    var firstName= NWF$(“#”+varFirstNameID);
    var fnVal= firstName.val();
    //control settings for the single line text box Store Client ID in JavaScript variable to YES, Client ID JavaScript variable name as varFirstNameID.  The setting above was for first name alone, I like using naming convention for Client ID and variables so its identifiable in the script and less chance of errors+ease of maintenance. This is applicable for all the controls in the section below for Last Name, Middle Initial, Department or School(lookup, drop down list) and Manager(cascaded filtered by department drop down list as well)
    var lastName= NWF$(“#”+varLastNameID);
    var lnVal= lastName.val();
    var middleInit = NWF$(“#”+varMiddleInitialID);
    var miVal= middleInit.val();
    var deptSchool= NWF$(“#”+varDepartmentSchoolID);
    var dsVal= deptSchool.val();
    var varManager= NWF$(“#”+varManagerID);
    var mVal= varManager.val();
    //alert(fnVal);
    //If validationError is true, then it means there is an empty value in the REQUIRED controls, so we have to fill them first after alerting the users.
    validationError= CheckValidationField(fnVal,lnVal,miVal,dsVal,mVal);
    //If it returns TRUE then there is an empty value, else if it is FALSE we are good to go.All required inputs are filled and systems can be submitted.
    if (validationError==true) {
    goStep(“2”);
    //Depending on what control is empty, focus is set to that control. If field is error: stop submission.
    if (fnVal==””) {NWF$(“#”+varFirstNameID).focus(); return false; }

    else if (lnVal==””) {NWF$(“#”+varLastNameID).focus(); return false; }

    else if (miVal==””) {NWF$(“#”+varMiddleInitialID).focus(); return false; }

    else if (dsVal==””) {NWF$(“#”+varDepartmentSchoolID).focus(); return false; }

    else {NWF$(“#”+varManagerID).focus(); return false; }
    }
    }
    function CheckValidationField(fnVal,lnVal,miVal,dsVal,mVal)
    {
    if (fnVal==”” || lnVal==”” || miVal==”” || dsVal==”” || mVal==””)
    {
    alert(“Required fields(First Name, Last Name, Middle Initial, Department or School and Manager) cannot blank.” );
    return true;
    }
    else
    {
    return false;
    }
    }

    This solved my validation issue in the form and trust this helps someone else as well facing the same situation. Thanks to all that tried to support and help.

  • References:
    François on SharePoint & more

My Validation issue is RESOLVED now. Feel free to use this as reference if you go through the same in your environment. Thanks.

Swetha.

One thought

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s