Question

Im trying to find, in my javascript, if i can identify in a variable if a "@" sign is present in the variable.

 e = _("email").value;

 if(e don't contain "@"){
     alert("Dosnt contain @");
 }
 else {
     alert("email has @");
 }

No correct solution

OTHER TIPS

You can use regular expressions to validate an email. Would be more easy to maintain and manage.

$('form input[name="email"]').blur(function () {
    var email = $(this).val();
    var re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/igm;
    if (re.test(email)) {
        $('.msg').hide();
        $('.success').show();
    } else {
    $('.msg').hide();
    $('.error').show();
    }
});

LIVE EXAMPLE

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top