Live Email Validation
An email field with JS validation toggling Bootstrap valid/invalid states.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:340px"><div class="card-body">
<label class="form-label small fw-semibold">Email</label>
<input type="email" class="form-control" id="vEmail" placeholder="you@example.com">
<div class="invalid-feedback" id="vMsg">Please enter a valid email.</div>
<button class="btn btn-primary btn-sm mt-3" id="vBtn">Validate</button>
</div></div>var e=document.getElementById('vEmail'),m=document.getElementById('vMsg');
document.getElementById('vBtn').onclick=function(){var ok=/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.value);e.classList.toggle('is-invalid',!ok);e.classList.toggle('is-valid',ok);m.style.display=ok?'none':'block'};Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.