Question: I tried creating a form like this. 

```html
<form>
  <input type="text" autocomplete="username" style="display:none;">
  <label for="password">password:</label><input type="password" autocomplete="current-password"><button>ok</button></div>
</form>
```

Note: the username is only there to shut chrome's devtools up. It prints a warning that a username should be required but I'm actually working on an electron app. Similarly the `<form>` is only there to shutup the devtools. I only needed the password field.

In any case if I press enter in the password field or click the OK button the form submits, or at least the page reloads, which was very surprising. There's no `submit` button and no JavaScript.

I would have expected a submit button to submit. I would not have expected pressing enter in the password field to submit nor pressing some random button element that has no handlers attached.

Is that the expected behavior?

Note: you can try it in the snippet above. Run the snippet, press ok.

Answer: 
By default this

```
<button>ok</button>

```

acts like this

```
<button type="submit">ok</button>

```

If you want it to not submit the form, you have to specify it's type as a normal button like so.

```
<button type="button">ok</button>

```
by default form submits on enter click if you donot want that to happen you have to stop it from being submitted

you can use jquery for this

```
<script>
$(form).on('submit', function(e){
e.preventDefault();
})
</script>

```