$('#username').focusout(function () {
//atribuindo valor do campo
var sEmail = $("username").val();
// filtros
var emailFilter = /^.+@.+\..{2,}$/;
var illegalChars = /[\(\)\<\>\,\;\:\\/\"\[\]]/;
// condição
if (!(emailFilter.test(sEmail)) || sEmail.match(illegalChars)) {
$("#icon_ok").hide();
$("#icon_cancel").show();
} else {
$("#icon_cancel").hide();
$("#icon_ok").show();
}
});
*** NOTE: If you do not type anything, it has no effect.