Okay so I'm trying to make a small little Javascript puzzle for a junior assignment, and I've only ever worked with number checking in text boxes, so excuse me if this seems slightly dumb.
Anyway, what I am trying to do is to check a textbox for a certain word, a password as you may, to advance to the next "level"
My Code:
var timesClicked = 100;
//Function to run the window alert a certain amount of times, as well as hide a certain answer
function changeFunc() {
if (timesClicked > 0){
if (timesClicked == 50) {
window.alert("N34T");
timesClicked--;
changeFunc();
}
else {
window.alert("NEAT");
timesClicked--;
changeFunc();
}
}
else{
window.alert("Sorry, no more answers may be dispensed at this time!");
}
}
//Function to go to the next puzzle
function nextPuzzle(){
if (document.getElementById('answer').value.indexOf("N34T") > -1) {
window.alert("Good Job");
}
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="puzzle01.js">
</script>
<title>Puzzle 1</title>
</head>
<header>
<h1>Puzzle 1!</h1>
<p> Please enjoy this puzzle's easiness, they will get harder!</p><br>
</header>
<body>
<p>
<input type="text" id="answer">
<button type="button" onclick="nextPuzzle()">Next Puzzle</button><br><br>
<button type="button" onclick="changeFunc()">Answers!</button>
</p>
</body>
</html>
Can anyone help? Thanks to anyone who can help in advance!
Aucun commentaire:
Enregistrer un commentaire