2

I am using jquery.validate.js for my front end validations. The email and other validations work on tab out, but the required validations work only on submitting the form. Is it possible to have all my required validations to work on tab-out as well. Here is a link from the site for the reference code and behaviour: http://jqueryvalidation.org/url-method/

UPDATE:
Adding the below piece of code inside the .validate function worked.

    onfocusout: function(element) {
       this.element(element);
    },

Here is the link - JSFIDDLE

Anuj
  • 1,203
  • 3
  • 13
  • 20

3 Answers3

4

Adding the below piece of code inside the .validate function worked.

onfocusout: function(element) {
   this.element(element);
},

Here is the link - JSFIDDLE

Anuj
  • 1,203
  • 3
  • 13
  • 20
1

you should create a blur function for your validate controls. for example:

 $("#password").on("blur", function () {
      if ($(this).val().trim().length == 0) {
           alert("Please enter your password");//or any process you want to be done
      }
 });
user2764860
  • 103
  • 6
AloneInTheDark
  • 938
  • 4
  • 15
  • 36
  • 1
    Thanks. But then, that is without using the plugin. I want to use the jquery validator. – Anuj Sep 26 '13 at 13:26
  • i think it's better to use this event for your required fields, instead of jquery validator. because i think jquery validator does not have a function for required validators to work at focus-out. – AloneInTheDark Sep 26 '13 at 13:38
  • The problem with blur is that if you use in two or more fields, you might have problems. – Marcelo Agimóvel Sep 29 '17 at 22:37
0

create blur event handler that validates an element use jquery validator valid method:

$(document).on('blur', 'elementSelector', function(e) {
    $(this).valid();
});

see example here.

alxndr
  • 106
  • 3