I was planning on using this password type style to let users check if they won. The codes are sent in an email then they come here to check if they won. If this was just for one winner the current system would work but i would like to add 5 and confirmPassword only allows one "code" to be valid. Is there anyway to add multiple valid ones?
<form>
<label for="pswd">ENTER YOUR RAFFLE NUMBER HERE</label>
<br>
<input type="password" id="pswd" class="box" placeholder="test" onkeydown="if (event.keyCode == 13) {document.getElementById('btnSearch').click(); return false;}"/>
<br>
<input type="button" class="confirm" id="btnSearch" value="Check Results" onclick="checkPswd();" />
</form>
</div>
<script type="text/javascript">
function checkPswd() {
var confirmPassword = "SampleCode";
var password = document.getElementById("pswd").value;
if (password == confirmPassword) {
window.location="winner.html";
}
else{
window.location="loser.html";
}
}
</script>
</body>
</html>
You can use array in Javascript:
const confirmPassword = ["SampleCode1", "SampleCode2", "SampleCode3","SampleCode4","SampleCode5"];
if(confirmPassword.includes(password)){
}