Source Code

<div class="container py-5 text-center">
  <button class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#bsdelModal">Delete project</button>
  <p class="small text-muted mt-3" id="bsdelResult"></p>
</div>

<div class="modal fade" id="bsdelModal" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header border-0">
        <h5 class="modal-title text-danger fw-bold">Delete "Northwind Marketing"?</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p class="small text-muted">This permanently deletes the project, its 48 files, and cannot be undone.</p>
        <label class="form-label small">Type <strong>delete northwind-marketing</strong> to confirm.</label>
        <input type="text" class="form-control" id="bsdelInput" autocomplete="off">
      </div>
      <div class="modal-footer border-0">
        <button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
        <button type="button" class="btn btn-danger" id="bsdelConfirm" disabled>Delete project</button>
      </div>
    </div>
  </div>
</div>

Bootstrap Type-to-Confirm Delete Modal — Free Snippet

Bootstrap Type-to-Confirm Delete Modal · Modals · Plain HTML, CSS & JS · Live preview

What's included

Features

Real Bootstrap 5.3 modal component, loaded from the actual CDN
Delete button stays genuinely disabled until an exact phrase match, not just a non-empty check
Live input validation with Bootstrap's real is-valid state on an exact match
Closes via Bootstrap's documented Modal API (getInstance().hide()), not manual class toggling
Fully resets on every close via Bootstrap's hidden.bs.modal event — no stale state on reopen
The same, stronger pattern production tools like GitHub use for irreversible actions

About this UI Snippet

Bootstrap Type-to-Confirm Delete Modal — HTML, CSS & JavaScript

Screenshot of the Bootstrap Type-to-Confirm Delete Modal snippet rendered live

A plain "Are you sure?" confirm dialog is easy to click through on autopilot. This snippet uses the stronger pattern real production tools reach for on genuinely irreversible actions: the Delete button inside a real Bootstrap 5.3 modal stays disabled until the visitor types an exact phrase — here, delete northwind-marketing — matched with a plain string comparison on every keystroke.

The input also gets Bootstrap's real is-valid styling the instant the phrase matches exactly, giving immediate positive feedback rather than leaving the visitor to guess whether they've typed it correctly. On close — whether by cancelling, confirming, or the backdrop — Bootstrap's own hidden.bs.modal event resets the input and re-disables the button, so a stale typed phrase from a previous open can never leave the button pre-enabled the next time.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Hand this snippet's HTML, CSS, and JS to an AI coding assistant like Claude and ask it to wire the confirm button to a real delete API call with a loading state and error handling, or to make the confirmation phrase dynamic based on a real resource name passed into the component. It's also a good exercise to ask the assistant to add a brief countdown (e.g. "wait 3 seconds") before the button becomes clickable, even after the phrase matches, as extra friction for the most destructive actions.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a Bootstrap 5.3 type-to-confirm delete modal, using the real Bootstrap CDN framework (bootstrap.min.css and bootstrap.bundle.min.js), not custom CSS made to resemble Bootstrap.

Requirements:
- A real Bootstrap modal (opened via data-bs-toggle="modal") warning about an irreversible delete action, with a text input and instructions telling the user to type an exact confirmation phrase.
- A Delete button that starts disabled and only becomes enabled once the input's value exactly matches the required phrase (checked live on every keystroke, not just on a separate confirm click) — apply Bootstrap's is-valid styling to the input once it matches.
- Clicking the enabled Delete button must close the modal using Bootstrap's documented JavaScript API (bootstrap.Modal.getInstance(element).hide()), not manual class or attribute manipulation, and show a confirmation message outside the modal.
- The modal must fully reset — clearing the input and re-disabling the Delete button — every time it's closed, using Bootstrap's own hidden.bs.modal event, so a previously typed phrase can never leave the button pre-enabled on the next open.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Step by step

How to Use

  1. 1
    Load the snippetClick the snippet in the sidebar Library tab. The preview loads a "Delete project" button.
  2. 2
    Open the modalClick it — a real Bootstrap modal opens with a disabled red Delete button.
  3. 3
    Type an incomplete or wrong phraseThe Delete button stays disabled no matter what's typed, until it matches exactly.
  4. 4
    Type the exact phrase shown"delete northwind-marketing" — the input turns green and the Delete button enables.
  5. 5
    Click DeleteThe modal closes and a confirmation message appears below the original button.
  6. 6
    Reopen the modalThe input is empty and the button disabled again — nothing carries over from the previous attempt.

Real-world uses

Common Use Cases

Deleting a project, repository, or account
Type-to-confirm is the appropriate friction level for an action that destroys real data with no undo.
Learning exact-match input validation
A clean example of gating an action behind a precise string comparison rather than a checkbox or a simple non-empty check.
Preventing accidental destructive clicks
Typing a specific phrase forces genuine intent in a way a single confirm click cannot, reducing costly mistakes.
Admin panels with high-stakes bulk actions
Reuse this pattern for "delete all users," "reset production database," or any admin action with serious consequences.

Got questions?

Frequently Asked Questions

Genuinely — its disabled property is set based on an exact string match, so it's functionally unclickable and correctly skipped in tab order until the phrase matches exactly.

Yes, this demo does a plain, case-sensitive trimmed comparison against the exact phrase. Add .toLowerCase() to both sides of the comparison if you want it case-insensitive.

No — this is a front-end demo showing a confirmation message. Wire the confirm button's click handler to a real DELETE API call before hiding the modal.

Bootstrap's hidden.bs.modal event clears the input and re-disables the button on every close, so reopening always starts from a clean, unconfirmed state.

Yes — build the PHRASE string from a real project/resource name variable instead of a hardcoded string, and update the visible instruction text to match.