I have created a form and a form validation script that checks if all fields are filled in, the name and city fields contain only letters, the age and phone fields contain only numbers and if the entered email is a valid one. When used in the console, all of the statements work, but when I fill in every field, or fill in invalid values in the email field or phone number and age field, I still get an error message saying that the name and city field must contain only letters.

I have tried writing out every statement alone and also checking them one by one.

HTML & JS

```
<form>
  <div class="form-group">
    <label for="inputName">Name</label>
    <input type="name" class="form-control" id="inputName" placeholder="Enter name">
  </div>
  <div class="form-group">
    <label for="inputName">Age</label>
    <input type="age" class="form-control" id="inputAge" placeholder="Enter age">
  </div>
  <div class="form-group">
    <label for="inputCity">City</label>
    <input type="city" class="form-control" id="inputCity" placeholder="Enter city">
  </div>
  <div class="form-group">
    <label for="InputEmail1">Email address</label>
    <input type="email" class="form-control" id="InputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
    <!-- <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> -->
  </div>
  <div class="form-group">
    <label for="inputPhone">Phone number</label>
    <input type="phone" class="form-control" id="inputPhone" placeholder="Phone number">
  </div>
  <button type="button" class="btn btn-primary submit">Submit</button>
  <button type="button" class="btn btn-primary erase">Erase</button>
</form>

<script>
function validateForm() {
    var name_cityRegex = /^[a-zA-Z]+$/;
    var emailRegex = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
    var age_phoneRegex = /^\d+$/;
    var nameValue = $('#inputName').val();
    var cityValue = $('#inputCity').val();
    var ageValue = $('#inputAge').val();
    var phoneValue = $('#inputPhone').val();
    var nameResult = name_cityRegex.test(nameValue);
    var cityResult = name_cityRegex.test(cityValue);
    var ageResult = age_phoneRegex.test(ageValue);
    var phoneResult = age_phoneRegex.test(phoneValue);
    var mailValue = $('#InputEmail1').val();
    var mailResult = emailRegex.test(mailValue);
    $(".btn.btn-primary.submit").click(function () {
        $('.form-control').each(function () {
            if ($(this).val() == "") {
                $('.alert.alert-danger').show();
            }
            else if (nameResult == false || cityResult == false) {
                $('.alert.alert-danger').text("Please use letters only in the fields 'Name' and 'City'");
                $('.alert.alert-danger').show();
                return false;
            }
            else if (ageResult == false || phoneResult == false) {
                $('.alert.alert-danger').text("Please use digits only in the fields 'Age' and 'Phone number'");
                $('.alert.alert-danger').show();
                return false;
            }
            else if (mailResult == false) {
                $('.alert.alert-danger').text("Please enter a valid email adress");
                $('.alert.alert-danger').show();
                return false
            }
            return true;
        })
});
</script>

```

When I leave all fields empty the warning is ok. But when I do anything else I only get the warning that I can only use letters in the fields Name and City.

All help is greatly appreciated for a beginner!