I'm trying to redirect my users on different URLs based on the text they enter in input and I've seen this question Need to redirect form to multiple URLs based on input
And I've tried the same thing but I don't know why this is not working for me please find my code below, whenever I click on the 'GO' button nothing happens.
<script type="text/javascript">
var urlMapping = {
"STRING1" : "https://google.com/",
"STRING2" : "https://stackoverflow.com/",
"STRING3" : "https://twitter.com/home"
}
$("#submit-form").click(function(){
var input = $("input").val().trim().toUpperCase();
if (urlMapping.hasOwnProperty(input)){
window.location = urlMapping[input];
}
else {
//if url not found, redirect to default url
window.location = "./default.html";
}
});
</script>
<form class="form-inline">
<div class="form-group">
<input type="text">
<button id="submit-form" type="button">Go</button>
</div>
</form>