
<form id="myForm">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email" required>
  
  <label for="age">Age (18 to 60):</label>
  <input type="number" id="age" name="age" min="18" max="60" required>
  
  <button type="submit">Submit</button>
</form>

<script>
  const form = document.getElementById('myForm');
  
  form.addEventListener('submit', (event) => {
    if (!form.checkValidity()) {
      // Prevent form submission if validation fails
      event.preventDefault();
      alert('Please fix the errors in the form.');
    }
  });
</script>

