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>#bsdelInput.is-valid { border-color: #16a34a; }const PHRASE = 'delete northwind-marketing';
const modalEl = document.getElementById('bsdelModal');
const input = document.getElementById('bsdelInput');
const confirmBtn = document.getElementById('bsdelConfirm');
const result = document.getElementById('bsdelResult');
input.addEventListener('input', () => {
const match = input.value.trim() === PHRASE;
confirmBtn.disabled = !match;
input.classList.toggle('is-valid', match);
});
confirmBtn.addEventListener('click', () => {
result.textContent = 'Project "Northwind Marketing" was deleted.';
bootstrap.Modal.getInstance(modalEl).hide();
});
// Every reopen starts from a clean, disabled state — a stale typed phrase
// from a previous open must never leave the confirm button pre-enabled.
modalEl.addEventListener('hidden.bs.modal', () => {
input.value = '';
input.classList.remove('is-valid');
confirmBtn.disabled = true;
});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
About this UI Snippet
Bootstrap Type-to-Confirm Delete Modal — HTML, CSS & JavaScript

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