is-valid
bootstrap5.css
bootstrap5.css
.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
border-color: #28a745;
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}
bootstrap5.css
.was-validated .form-control:valid ~ .valid-feedback,
.was-validated .form-control:valid ~ .valid-tooltip,
.form-control.is-valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated textarea.form-control:valid,
textarea.form-control.is-valid {
padding-right: calc(1.5em + 0.75rem);
background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
}
bootstrap5.css
.was-validated .custom-select:valid:focus,
.custom-select.is-valid:focus {
border-color: #28a745;
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}
bootstrap5.css
.was-validated .custom-select:valid ~ .valid-feedback,
.was-validated .custom-select:valid ~ .valid-tooltip,
.custom-select.is-valid ~ .valid-feedback,
.custom-select.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .form-control-file:valid ~ .valid-feedback,
.was-validated .form-control-file:valid ~ .valid-tooltip,
.form-control-file.is-valid ~ .valid-feedback,
.form-control-file.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .form-check-input:valid ~ .form-check-label,
.form-check-input.is-valid ~ .form-check-label {
color: #28a745;
}
bootstrap5.css
.was-validated .form-check-input:valid ~ .valid-feedback,
.was-validated .form-check-input:valid ~ .valid-tooltip,
.form-check-input.is-valid ~ .valid-feedback,
.form-check-input.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .custom-control-input:valid ~ .custom-control-label,
.custom-control-input.is-valid ~ .custom-control-label {
color: #28a745;
}
bootstrap5.css
.was-validated .custom-control-input:valid ~ .custom-control-label::before,
.custom-control-input.is-valid ~ .custom-control-label::before {
border-color: #28a745;
}
bootstrap5.css
.was-validated .custom-control-input:valid ~ .valid-feedback,
.was-validated .custom-control-input:valid ~ .valid-tooltip,
.custom-control-input.is-valid ~ .valid-feedback,
.custom-control-input.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .custom-control-input:valid:checked ~ .custom-control-label::before,
.custom-control-input.is-valid:checked ~ .custom-control-label::before {
border-color: #34ce57;
background-color: #34ce57;
}
bootstrap5.css
.was-validated .custom-control-input:valid:focus ~ .custom-control-label::before,
.custom-control-input.is-valid:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}
bootstrap5.css
.was-validated .custom-control-input:valid:focus:not(:checked) ~ .custom-control-label::before,
.custom-control-input.is-valid:focus:not(:checked) ~ .custom-control-label::before {
border-color: #28a745;
}
bootstrap5.css
.was-validated .custom-file-input:valid ~ .custom-file-label,
.custom-file-input.is-valid ~ .custom-file-label {
border-color: #28a745;
}
bootstrap5.css
.was-validated .custom-file-input:valid ~ .valid-feedback,
.was-validated .custom-file-input:valid ~ .valid-tooltip,
.custom-file-input.is-valid ~ .valid-feedback,
.custom-file-input.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .custom-file-input:valid:focus ~ .custom-file-label,
.custom-file-input.is-valid:focus ~ .custom-file-label {
border-color: #28a745;
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}
html bootstrap5 Sample
サーバー側で入力検証を行う場合:is-valid
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationServer01">姓</label>
<input type="text" class="form-control is-valid" id="validationServer01" placeholder="First name" value="山田"
required>
</div>
<div class="col-md-6 mb-3">
<label for="validationServer02">名</label>
<input type="text" class="form-control is-valid" id="validationServer02" placeholder="Last name" value="太郎"
required>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationServer03">市町村</label>
<input type="text" class="form-control is-invalid" id="validationServer03" placeholder="市町村名を入力" required>
<div class="invalid-feedback">市町村名を入力してください</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationServer04">都道府県</label>
<input type="text" class="form-control is-invalid" id="validationServer04" placeholder="都道府県名を入力" required>
<div class="invalid-feedback">都道府県名を入力してください</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationServer05">郵便番号</label>
<input type="text" class="form-control is-invalid" id="validationServer05" placeholder="郵便番号を入力" required>
<div class="invalid-feedback">郵便番号を入力してください</div>
</div>
</div>
<button class="btn btn-primary" type="submit">送信する</button>
</form>