I am trying to make e-mail validation in jQuery, but it really doesn't work in the way I want. Please share your knowledge with me, thank you in advance !
So first if should check if there is more than 1 @ -> if is "invalid", if it is not 'else if' check if there is at least 1 '@' and '.' , if this is wrong 'else' it is invalid. But it doesn't work :(
$(document).ready(function(){
$('input').focusout(function(){
if($(this).val().indexOf('@') > 0){
$('.output').html('Invalid E-mail')
}else if($(this).val().indexOf('@') > -1 &&
$(this).val().indexOf('.') > -1){
$('.output').html('Valid E-mail');
}else{
$('.output').html('Invalid E-mail')
}
});
HTML:
<input name='input' placeholder='Your E-mail'/></br></br>
<p class='output'></p>