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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -