-3
$('#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, do not have any effect.
$("username").val()
shouldn’t be$("#username").val()
or$(this).val()
?– Woss
Our brother, what a detail!!! Thank you very much !!!
– S. Santos
@Andersoncarloswoss how do I make the icons disappear if I do not type anything, pq qnd I click on the field and do not type anything, qnd I click off, the icon appears, in the case as I did not type it was not to give any effect
– S. Santos
How do I make it already validate as the user type? Why does it only validate when I click out...
– S. Santos