cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

instant forms validation

Jump to solution

I have a form that is used to request new computer names. I have some code that uses NWF jQuery to validate against all exisiting hostnames, but it seems to do the validation OnSubmit, not onBlur. I want to provide the user with feedback instantly that their hostname is not good because when the form is submitted I need to send one and only one email with the requested hostname.

 

Is there a way to get a form field to vvalidate onBlur, rather than on submit?

Labels: (3)
0 Kudos
Reply
2 Replies
Highlighted
Nintex Newbie

Re: instant forms validation

Jump to solution

Hi there,

 

The following will validate an input field when the focus changes from it:

NWF$(document).ready(function() {       // Select using a unique class name we have supplied, choose input child element.     NWF$(".validateMe input:first-child").change(function() {              // Check value of the input field and set style.         if(NWF$(this).val() != "boo") {             NWF$(this).css(                 { "border-color": "#FF0000",                      "border-width":"2px",                        "border-style":"solid"}             );         }         else {             NWF$(this).css(                 { "border-color": "#000",                      "border-width":"1px",                        "border-style":"solid"}             );         }              }); });  

 

In the above example we check the input field with the class 'validateMe' associated with it.  If the input field does not have a value of "boo" when changed then a red border is applied, a black border is applied when the input value equals "boo".

 

Ensure the input field has the unique css class so it can be located:

 

Put the validation JavaScript straight into Settings > Custom JavaScript.

 

You would also need to validate this on form save as the above will not prevent the user form saving invalid items.

 

Hope this gets you started.

View solution in original post

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: instant forms validation

Jump to solution

Thanks Berry!

Very helpful.

0 Kudos
Reply