lundi 20 juin 2016

jQuery - n.blur is not a function


This code isn't working. The console says n.blur is not a function.

var name = '',
    formElement = '',
    fullname = $('.form input[name="user"]'),
    email = $('.form input[name="pass"]');

$('.form input').click(function() {
    name = $(this).attr('name');
    formElement = $('.form input[name="'+name+'"]');
});

formElement.blur(function() {
    if(formElement.val().length === 0) {
        formElement.closest('.form-group').addClass('has-error');
    } else {
        formElement.closest('.form-group').removeClass('has-error');
    }
});

Aucun commentaire:

Enregistrer un commentaire