Question: There is a field to enter the name and password, as well as the login button. After entering the correct password and name, it is necessary that pressing the enter button triggers the login function, and if the entered password or name is incorrect, an input error message is displayed. An event click on enter should work regardless of the field in which the courses are located and regardless of whether the user has entered the data or not. It is necessary to implement using pure JS. Thank you in advance.

```
<form>
  <div class="group">
    <input type="text" id="Name">
    <label>Name</label>
  </div>
  <div class="group">
    <input type="password" id="Pass">
    <label>Password</label>
  </div>
  <button type="button">Log In</button>
</form>

```

JS 

```
function authorization(name, pass) {
  name = document.getElementById("Name").value;
  pass = document.getElementById("Pass").value;

  if (name === "name") {
    if (pass === "pass") {
      document.location.href = 'index.html';
    } else {
      alert("Wrong password");
    }
  } else {
    alert("Wrong date")
  }
}

```

Answer: 
Change the button into a submit button, and bind a `submit` event listener to the form element.

Enter in an input in a form with only one submit button will trigger a submit event.
This code helped me.

```
function login () {
      console.log('Вы нажали ENTER')
}

<form>
  <div class="group">
    <input onkeydown="if(event.keyCode == 13) login();" type="text" id="Name">
    <label>Name</label>
  </div>
  <div class="group">
    <input onkeydown="if(event.keyCode == 13) login();" type="text" id="Pass">
    <label>Password</label>
  </div>
  <button type="button">Log In</button>
</form>

```