Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <title>Title</title>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- Bootstrap CSS v5.3.0 -->
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"
- integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM"
- crossorigin="anonymous">
- </head>
- <body>
- <form class="p-3">
- <fieldset class="form-control-lg">
- <div class="row mb-3">
- <div class="col-1">
- <label for="cognome" class="form-label">LARGE</label>
- </div>
- <div class="col-auto">
- <input type="text" class="form-control" id="cognome">
- </div>
- </div>
- </fieldset>
- <fieldset disabled>
- <div class="row mb-3">
- <div class="col-1">
- <label for="nome" class="form-label">Normal</label>
- </div>
- <div class="col-auto">
- <input type="text" class="form-control" id="nome" value="test prova">
- </div>
- </div>
- </fieldset>
- <fieldset class="form-control-sm">
- <div class="row mb-3">
- <div class="col-1">
- <label for="cognome_copia" class="form-label">small</label>
- </div>
- <div class="col-auto">
- <input type="text" class="form-control" readonly value="standard" id="cognome_copia">
- </div>
- </div>
- </fieldset>
- <div class="row mb-3">
- <div class="col-auto">
- <select id="provincia" class="form-select form-select-sm">
- <option selected>Scegli una provincia</option>
- <option value="MI">Milano</option>
- <option value="RM">Roma</option>
- <option value="PA">Palermo</option>
- </select>
- </div>
- </div>
- <br><br><br>
- <div class="form-check">
- <label class="form-check-label" for="check1">C++</label>
- <input class="form-check-input" name="linguaggio" type="checkbox" id="check1">
- </div>
- <div class="form-check">
- <label class="form-check-label" for="check2">Javascript</label>
- <input class="form-check-input" name="linguaggio" type="checkbox" id="check2">
- </div>
- <div class="form-check form-switch">
- <label class="form-check-label" for="check3">Precedenti Esperienze</label>
- <input class="form-check-input" name="esperienze" type="checkbox" id="check3">
- </div>
- <br><br>
- <div class="form-check">
- <label class="form-check-label" for="radio1">M</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio1">
- </div>
- <div class="form-check">
- <label class="form-check-label" for="radio2">F</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio2">
- </div>
- <br><br>
- <div class="form-check form-check-inline">
- <label class="form-check-label" for="radio3">M</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio3">
- </div>
- <div class="form-check form-check-inline">
- <label class="form-check-label" for="radio4">F</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio4">
- </div>
- <br><br>
- <div class="form-check form-check-reverse">
- <label class="form-check-label" for="radio5">M</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio5">
- </div>
- <div class="form-check form-check-reverse">
- <label class="form-check-label" for="radio6">F</label>
- <input class="form-check-input" name="sesso" type="radio" id="radio6">
- </div>
- <div class="form-floating mb-3">
- <input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
- <label for="floatingInput">Email</label>
- </div>
- <div class="form-floating">
- <input type="password" class="form-control" id="floatingPassword" placeholder="Password">
- <label for="floatingPassword">Password</label>
- </div>
- <br><br>
- <div class="input-group mb-3">
- <span class="input-group-text">@</span>
- <input id="user" type="text" class="form-control" placeholder="Username"">
- </div>
- <div class="input-group mb-3">
- <span class="input-group-text">$</span>
- <input id="dollaro" type="text" class="form-control">
- <span class="input-group-text">.00</span>
- </div>
- <br><br>
- <label for="intervallo" class="form-label">Voto</label>
- <input type="range" class="form-range" min="1" max="10" step="0.5" id="intervallo">
- </form>
- <br><br>
- <div class="container">
- <form class="row" id="con_validazione" novalidate action="elabora.php">
- <div class="col-md-4">
- <label for="il_nome" class="form-label">Nome</label>
- <input type="text" class="form-control" id="il_nome" value="Sandro">
- <div class="valid-feedback">
- OK!
- </div>
- <div class="invalid-feedback">
- Errore!
- </div>
- </div>
- <div class="col-md-4">
- <label for="il_cognome" class="form-label">Cognome</label>
- <input type="text" class="form-control" id="il_cognome" value="Parchielli" required>
- <div class="valid-feedback">
- OK!
- </div>
- </div>
- <div class="col-md-4">
- <label for="username" class="form-label">Username</label>
- <div class="input-group has-validation">
- <span class="input-group-text" id="inputGroupPrepend">@</span>
- <input type="text" class="form-control" id="username" required>
- <div class="invalid-feedback">
- Scegliere uno username.
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <label for="citta" class="form-label">Città</label>
- <input type="text" class="form-control" id="citta" required>
- <div class="invalid-feedback">
- Scegliere una cittá valida
- </div>
- </div>
- <div class="col-md-3">
- <label for="nazione" class="form-label">Nazione</label>
- <select class="form-select" id="nazione" required>
- <option selected disabled value="">Scegli...</option>
- <option>...</option>
- </select>
- <div class="invalid-feedback">
- Scegli una nazione valida.
- </div>
- </div>
- <div class="col-md-3">
- <label for="zip" class="form-label">Zip</label>
- <input type="text" class="form-control" id="zip" required>
- <div class="invalid-feedback">
- Scegli uno zip valido.
- </div>
- </div>
- <div class="col-12">
- <div class="form-check">
- <input class="form-check-input" type="checkbox" value="" id="accettazione" required>
- <label class="form-check-label" for="accettazione">
- Accetto le condizioni
- </label>
- <div class="invalid-feedback">
- Devi accettare per proseguire
- </div>
- </div>
- </div>
- <div class="col-12">
- <button class="btn btn-primary" type="submit">INVIA</button>
- </div>
- </form>
- </div>
- <!-- Bootstrap JavaScript Libraries -->
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
- integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz"
- crossorigin="anonymous"></script>
- <script>
- document.getElementById("con_validazione")
- .addEventListener("submit", function(event) {
- //ERRATA CORRIGE RISPETTO AL VIDEO
- //resetto lo stato della casella nome per
- //rifare il check sul submit
- const nome = document.getElementById("il_nome");
- nome.classList.remove("is-valid"); nome.classList.remove("is-invalid");
- // *************************************************************
- //ERRATA CORRIGE RISPETTO AL VIDEO: aggiungo il controllo customizzato sul nome
- if (!(check_nome(nome) && this.checkValidity() )) {
- event.preventDefault();
- event.stopPropagation();
- //ribadisco lo stato dei feedback sul nome causa interferenze con checkValidity
- //diversamente ci sono situazioni in cui rimangono visualizzati sia
- //il messaggio di dato valido sia quello di dato non valido
- check_nome();
- }
- this.classList.add('was-validated');
- });
- //ERRATA CORRIGE RISPETTO AL VIDEO: ho creato
- //una funzione di check isolata per poterla
- //richiamare anche al submit (vedi sopra)
- document.getElementById("il_nome")
- .addEventListener("blur", function() {
- check_nome(this);
- });
- //questa funzione nel video era in linea nell'addEventListener
- function check_nome(nome)
- {
- //pulisco la classList
- nome.classList.remove("is-valid"); nome.classList.remove("is-invalid");
- if(nome.value.length<3)
- {
- nome.classList.add("is-invalid");
- return false;
- }
- else
- {
- nome.classList.add("is-valid");
- return true;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement