I need to redirect to a link only if the code entered is correct. So the concept is the person inputs a code like 1234 and goes to a.com, but if someone doesnt write that code, they dont go anywhere
I have tried the code below but nothing worked. I change the web names to a.com as the target and b.com as the site redirecting to a.com
<body>
<input type="text" placeholder="Enter Your Code" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Your Code'" maxlength="10" id="input-code">
<p><a href="#" class="btn" onclick="return btntest_onclick()">VERIFY NOW</a></p>
<script>
if (document.getElementById('input-code').value == '1234'){
function btntest_onclick(){
window.location.href = "a.com";
}
btntest_onclick()
}else{
function btntest_onclick(){
window.location.href = "b.com";
}
btntest_onclick()
}
I expect to go to a.com upon giving the code 1234, but it does not happen