Question: I have a table within a form. The table contains some form fields, but there are form fields outside of the table (but still within the form) too.

I know that Enter and Return are traditionally used to submit a form via the keyboard, but I want to stop this behaviour for fields within the table. For example, if I focus a field within the table and hit Enter/Return, nothing happens. If I focus a field outside of the table (but still within the form) then for it to submit as normal.

I have a jQuery plugin that targets this table. Simplified, this is what I've tried this far:

```
base.on('keydown', function(e) {
    if (e.keyCode == 13) {
        e.stopPropagation();
        return false;
    }
});

```

Where `base` is the table jQuery object. This is within my plugin's `init` method. However, hitting Enter still submits the form.

Where am I going wrong?

**EDIT:** Some simplified HTML:

```
<form method="" action="">
  <input type="text" /><!--this should still submit on Enter-->
  <table>
    <tbody>
      <tr>
        <td>
          <input type="text" /><!--this should NOT submit on Enter-->
        </td>
      </tr>
    </tbody>
  </table>
</form>

```

Answer: 
`e.preventDefault()` rather than `e.stopPropagation()`. stopPropagation only stops it bubbling up to higher DOM nodes, it doesn't prevent the default action.
I found this Q/A trying to sort out a similar situation where I have multiple forms and enter would not do what I wanted. In my specific case, I would dynamically add a new `<div id="D1">` D1, D2, D3, etc, and each new div has a form that would reload that div from the same php code that created it, only also with a POST. 

Unrelated first problem was I couldn't dynamically create a new function with each div, so I passed the D1, etc, descriptor as an argument to the Javascript function:

```
<script type="text/javascript">
function formSubmit ( divid ) {
    // post data
    event.preventDefault();
    $.post( "make-my-form-div.php", 
            $("#form"+divid).serialize(), 
            function(data){
                $("#"+divid).html(data);
            });
    return false;
}
</script>

```

You will see the requisite `event.preventDefault();` and `return false;` that works for the answers in this thread. It didn't work for me. If I click the Submit in any one form, that one div would reload with the correct data. Hitting enter would cause default action and reload the entire page, leaving me with only 1 div.

[This Answer worked](https://stackoverflow.com/a/12031579/946112): I needed a unique ID and NAME for the different forms. Initially, they were `<INPUT TYPE="button" VALUE="Submit" onClick="formSubmit('<?php echo $divid ?>');">` but once I added unique ID and NAMES, such as "formD1", etc, it all started working correctly.