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.
change button type submit. inside from element button which type is submit is associated with submit event of the form.
and submit event works only when you are in focus in inputs fields
 Log In