javascript - prevent form from submitting when keypress = 13 on a certain inputbox inside a form -


Good day,

Can someone please help me whenever I press a form "Enter" on a certain input box inside

I have a table where usage can be dynamically add / remove row and I also have an input box where the user types / input rows that he added Want to What I want to do is that, instead of clicking on the row button, adding the user to the add row input box without actually submitting the form, press Enter.

Here's my JS:

my html

  & lt; Form & gt; & Lt; Div & gt; & Lt; Input name = 'amout' & gt; & Lt; / Zodiac & gt; & Lt; Input name = 'qty' & gt; & Lt; / Zodiac & gt; .. etc & lt; / Div & gt; & Lt; Input type = "text" id = "toBeAdded" class = "form-control" & gt; & Lt; Div class = "input-group-btn" & gt; & Lt; Button type = "button" id = "btnadrew" class = "btn btn-primary" & gt; Add Row & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Form & gt;  

The above code does not work, it displays the log message, but will then submit it after the form. Change the funnel event to keydown

("key down" , Function (e) {

You can click << code>

  $ ("# toBeAdded"). 


Comments