I cant find a working way to redirect the users on my website based on what they type on a text field. I have tried using this code bellow but no success. Can someone please guide me.
function valForm() {
var firstVal = document.getElementById("nextId");
if (firstVal.length == 0) {
error += "Desk Number is required\n";
}
if (firstVal == 430) {
window.location = "https://awebsite";
}
if (error) {
alert(error);
}
}
<input type="text" placeholder="License Plate" class="form-control" id="name-form9-z" />
<div class="ticketId">
<input type="text" placeholder="Ticket ID" class="form-control" id="nextId">
</div>
<button class="btn btn-primary display-4" type="button" onclick="valform()">next</button>