How to press enter in input type text call function javascript by not submit form ?
When fill data into input type text and press enter keyboard i want only to call function detect_enter_keyboard(event) by not to submit form.
How can i do that ?
https://jsfiddle.net/atuyx7qc/
<form>
<input type="text" name="user" onkeypress="detect_enter_keyboard(event)">
<input name="btnLogin" onclick="test_fn();" type="button" value="Send">
</form>
<script>
function detect_enter_keyboard(event) {
var key_board_keycode = event.which || event.keyCode;
if(key_board_keycode == 13)
{
test_fn();
}
}
</script>
<script>
function test_fn(){
alert("555555");
}
</script>