Good day,
Can anyone please help me how can I stop my form from submitting whenever I press "enter" on a certain input box inside a form.
I have a table where use can dynamically add/remove row. And I have also an input box where user types/input number of rows he/she want to add. What I want to do is, the user can press enter instead of clicking the add row button when hes on the add row input box without actually submitting the form.
here is my js:
$("#toBeAdded").bind("keyup",function(e){
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
console.log("enter");
return false;
e.preventDefault();
}
});
my html
<form>
<div>
<input name='amout'></amount><input name='qty'></amount>..etc
</div>
<input type="text" id="toBeAdded" class="form-control">
<div class="input-group-btn ">
<button type="button" id="btnAddRow" class="btn btn-primary ">Add Row</button>
</div>
</form>
the above code doesnt work, it does display log message but then it will submit the form after. any thoughts please