I have a textarea in an html file. I am using the javascript code below. I want that when the user enters in the textareathe following sentences (with the break line),
hello
hi
how are you
javascript redirects him to a website. I tried to do this but didn't work. CAN ANYBODY PLEASE HELP ME? THANKS IN ADVANCE:)
Javascript code
function myFunction() {
var x = document.getElementById("myTextarea").value;
if (x === "hello" + \n + "hi" + \n + "how are you") {
document.location.href = "http://www.google.com";
return false;
}
else {
alert('ok i knew it');
return false;
}
}
\ns should also be enclosed within quotes.ifstatement.