Этот код не работает. Консоль говорит n.blur is not a function
.jQuery - n.blur не является функцией
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');
}
});
Вы не определяете 'formElement' до события' click', как вы ожидаете его работы? –