File "test01.html"

Full Path: /home/analogde/www/Design/fileman/Fusion/formulaire_bootstrap/test01.html
File size: 2.02 KB
MIME-type: text/html
Charset: utf-8

<!--
https://mailbrother.com/blog/a-guide-to-bootstrap-5-form-validation

https://www.codexworld.com/code-snippets/html-form-validation-with-bootstrap/

https://www.geeksforgeeks.org/how-to-validate-email-id-in-jquery/

https://emretulek.github.io/jbvalidator/index.html

https://www.jqueryscript.net/form/bootstrap-compatible-validator.html


https://emretulek.github.io/jbvalidator/index.html  +++++

-->

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap Form Validation Example</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
  <div class="container">
    <h1>Bootstrap Form Validation Example</h1>
    <form id="myForm" class="needs-validation" novalidate>
      <div class="form-group">
        <label for="name">Name:</label>
        <input type="text" class="form-control" id="name" required>
        <div class="invalid-feedback">
          Please enter your name.
        </div>
      </div>
      <div class="form-group">
        <label for="email">Email:</label>
        <input type="email" class="form-control" id="email" required>
        <div class="invalid-feedback">
          Please enter a valid email address.
        </div>
      </div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </form>
  </div>

  <script>
    // Add event listener to the form's submit event
    document.getElementById("myForm").addEventListener("submit", function(event) {
      event.preventDefault(); // Prevent form submission if validation fails
      if (this.checkValidity() === false) {
        event.stopPropagation(); // Stop the event from propagating further
      }
      this.classList.add("was-validated"); // Add 'was-validated' class to enable Bootstrap's styling
    }, false);
  </script>
</body>
</html>