I have a page with an input field where I'd like to send the user to the URL they enter in the input, with -.html appended at the end. My HTML is as follows:
<form name="codeform">
<input type="text" id="code" name="code" autofocus>
</form>
<a href="#" class="button" id="submit">SUBMIT</a>
And my javascript:
$('#submit').click(function () { location.href = window.document.codeform.code.value + '.html'; });
When the user clicks the button, the script works as intended and the user goes to the page. But I'd also like the script to execute when the return key is pressed. Right now, when the return key is pressed, it tries to submit the form and I end up with a query string.
What is the best way to send the user to the page whether the button or return key is pressed?