Snippets Input

Bootstrap 5 Email Input with Animated Underline and Validation

An email input with an animated underline, live validation and a clear success state before the subscribe button unlocks.

Bootstrap 5 No jQuery Aug 2019 5.8K views

<section class="wdw-stage">
  <div class="container" style="max-width: 680px">
    <div class="wdw-card p-4 p-md-5">
      <span class="wdw-eyebrow">Stay in the loop</span>
      <h2 class="wdw-heading display-6 mt-2 mb-2">What's your email?</h2>
      <p class="wdw-muted mb-4">One short note a month. No spam, unsubscribe anytime.</p>

      <form id="wfForm" novalidate>
        <div class="input-group wf-field" id="wfField">
          <span class="input-group-text" aria-hidden="true"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg></span>
          <label for="wfEmail" class="visually-hidden">Email address</label>
          <input type="email" id="wfEmail" class="form-control wf-input" placeholder="[email protected]" autocomplete="email" value="[email protected]" aria-describedby="wfHint">
          <span class="input-group-text wf-state" id="wfState" aria-hidden="true"></span>
          <span class="wf-line" aria-hidden="true"></span>
        </div>
        <div class="d-flex justify-content-between align-items-center mt-3 gap-3 flex-wrap">
          <span class="small wdw-muted" id="wfHint" role="status" aria-live="polite">Looks good.</span>
          <button type="submit" class="btn btn-primary rounded-pill px-4" id="wfBtn">Subscribe</button>
        </div>
      </form>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.