I am working on my assignment where I have to ask a user to type specific letter (capital), if not then I am not supposed to process the input data
Tried to use if and specified which letters I am expecting
function myFunction() {
var bokstav, r4;
bokstav = document.getElementById("tipping").value;
if (bokstav !== "H" || bokstav !== "U" || bokstav !== "B") {
r4 = "Du har ikke brukt stort bokstav eller tastet ugyldig tegn";
} else if (bokstav = "H") {
r4 = "Hjemme";
} else if (bokstav = "U") {
r4 = "Uavgjort";
} else {
r4 = "Borte";
}
document.getElementById("demo").innerHTML = r4;
}
<p>Type H/B/U:</p>
<input id="tipping" value="H" type="text" />
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
I expect the user to type just H, U or B. Then if the "H" is typed then "Hjemme" is displayed on the screen, if "B" is typed then to show "Borte" on the screen and so on. Otherwise ask the user to type only H, U, B ( capital)