i need a help for javascript.
For example i have an x value and i want to two or multiple values equal to x in if statement.
if x equals to apple or pear or banana it writes "fruits". How can i do this?
I've tried || and && operators. I tried to put "," and ";" between the values.
<form name="formname" action="send.php" method="post" onsubmit="return confirm();">
Type your name : <input type="text" name="name"><br>
<input type="submit" value="Send">
</form>
<script>
function confirm() {
var x = document.formname.name.value;
if (x == "") {
alert("You need to fill here!");
return false;
}
else if (x == "Lisa" /* and a little more names... */) {
alert("You can't enter here");
return false;
}
else {
alert("Welcome");
return false;
}
}
</script>
When I put "," between values in "else if" statement and when I type else name from "else if" statement, it writes "You can't enter here" again. But i except it will write "Welcome".