cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

JavaScript to trigger form validation rules

Jump to solution

I am building a 2-page form using Nintex Forms 2013 v2.8.1

Page 1 - Display input controls to collect information

Page 2 - Display the summary of the entered information

The design of Page 1 includes one panel (named Panel1), "Next" and "Cancel" button.

The design of Page 2 includes one panel (named Panel2), "Previous", "Submit" and "Cancel" button.

The purpose of the "Next" button would be triggering validation rules by JavaScript using NWF.Formfiller.Functions.ProcessFormsValidation().

If it passes the validation, then page 2 would be displayed. User can review the entered information before clicking the "Submit" button.

However, I was not able to find any documentation about the syntax/signature of the ProcessFormsValidation() function.

If I call it with no parameters, it will always return true.

Here is the pseudo-code of the "Next" button (with Button type = "JavaScript").

if (form validation is passed) {

   hidePanel1;

   showPanel2;

}

If the button type is "Save" or "Save and Submit", it will trigger form validation and submit to SharePoint list.

If the button type is "JavaScript", I need the JavaScript function to trigger form validation without submitting to the SharePoint list.

Nintex Support is not able to provide support documentation on this JavaScript function and refers me to Community site for help.

Similar question was found in thread 4539 and 7709, but both were unanswered.

How to fire OOTB Nintex form validation using jQuery?

Validation on Multi-Panel Form with Next Buttons

Let me know if you have a solution or any workaround.

Thanks.

Johnny

Labels: (1)
Reply
18 Replies
Automation Master
Automation Master

Re: JavaScript to trigger form validation rules

Jump to solution

Hello Johnny Kwok​ – If you take a look at this thread, I believe Themos K​ has recently figured out the same problem you're facing.

So within the logic of your "Next" click, after validation is invoked, you'd want to do the following:

if (NWF$('.nf-validation-summary').css('display') == 'none') {

  hidePanel1;

  showPanel2;

}

Reply
Not applicable

Re: JavaScript to trigger form validation rules

Jump to solution

Hi Patrick,

Thanks for your information.

I tested your suggestion for "Next" button with button type = "JavaScript" and "Save".

If button type = "JavaScript", Nintex form validation did not trigger at all and jumps to page 2. CSS display value maintains "none".

If button type = "Save", Nintex form validation triggered and changes CSS display value to "block" after the executing the script when there is validation error. If there is no validation error, it will write to SharePoint list without hiding panel 1 and showing panel 2.

This observation confirms that the JavaScript of the "Next" button is executed BEFORE the form validation.

Your suggestion will work if the JavaScript is executed AFTER the form validation.

It seems we need the JavaScript to be run within the "Save" mechanism - after form validation but before writing to SharePoint list.

From one of Themos K reply, do you know where to place the script NWF$(document).submit() ? Does this imitate the Nintex built-in "Save" mechanism ?

Thanks.

Johnny

Reply
Automation Master
Automation Master

Re: JavaScript to trigger form validation rules

Jump to solution

Right, this would be the custom code used on a "JavaScript" type button in order to imitate the built in save functionality.

Reply
themos
Nintex Newbie

Re: JavaScript to trigger form validation rules

Jump to solution

Hey Johnny,

The NWF$(document).submit() will execute JS code AFTER the form is submitted, it will not trigger the submission for you..

As a suggestion, why don't you simply use custom JS validations for the 'Next' button? i.e.

if (testKeyCode == '') {

    alert('Test Key Code cannot be empty');

    return;

}

Reply
Not applicable

Re: JavaScript to trigger form validation rules

Jump to solution

Thanks Themos.

After adding NWF$(document).submit() in the main Custom JavaScript section, my page switching script is now executed AFTER form validation when "Next" button is clicked.

Note that the "Next" button has to be "Save" button type in order to trigger the submission and form validation.

Given the button type is "Save", when there is no error, CSS display value = 'none'. Page 2 of the form just flashes, and then the data is written to SharePoint list right away. The requirement of this form is to display page 2 for user review before final submission.

I am now back to square one which I expect the "Next" button with button type = "JavaScript" can trigger the form validation and return "true" or "false" for my next operation.

My form is so long and complex and it would not be possible to rewrite all the Nintex validation rules into pure JavaScript validations.

Thanks.

Johnny

Reply
Automation Master
Automation Master

Re: JavaScript to trigger form validation rules

Jump to solution

Hey ‌ -- did you ever find a solution to your problem?

0 Kudos
Reply
franco89
Nintex Newbie

Re: JavaScript to trigger form validation rules

Jump to solution

I also need a solution to this!

0 Kudos
Reply
Highlighted
omar_taha
Nintex Newbie

Re: JavaScript to trigger form validation rules

Jump to solution

No I didn't find any solution for nintex validation, I did a custom javascript validation.

0 Kudos
Reply
franco89
Nintex Newbie

Re: JavaScript to trigger form validation rules

Jump to solution

Could you share it?

0 Kudos
Reply