To check whether the email address is from gmail I tried the following jQuery code but I am getting Uncaught TypeError: Cannot call method 'indexOf' of undefined
CODE
$( document ).ready(function() {
$("#sendit").click(
function() {
var str1 = $("#email").value;
var str2 = "gmail.com";
if(str1.indexOf(str2) != -1){
alert("found");
}
});
});
Is there any error in my syntax?
.value), which will returnundefined. That's a runtime error and a logic error in your code (but not a syntax error).