javascript - Indexof() returning -1 -
been making simple form + data validation thing, i'm using indexof make sure there "@" , "." in email address, returning -1.
var custemail = document.getelementbyid("custemail"); if (custemail.value == "" || custemail.value.indexof("@" == -1) || custemail.value.indexof("." == -1)) { alert("you must enter valid email address!\n" }
i've tried changing indexof check different letters instead of symbols, still returns -1, makes me think i'm trying data incorrectly.
your parens in wrong place
custemail.value.indexof("@") == -1 || custemail.value.indexof(".") == -1
Comments
Post a Comment