Sweet Alert With Confirmation Code In jQuery

Hello guys, Hope you all are doing well. In this article, I will explain how to ask for a confirmation code in Sweetalert.


You need to attach sweetalert.min.js to your web page.

Add The Below Code

var ConfirmIput = Math.floor(1000 + Math.random() * 9000);

  title: "<h2 style='color: #575757 !important;'>Are you sure?</h2>",
  text: 'Are you sure you want to update? <br><br> Type ' + ConfirmIput + ' to confirm',
  type: "input",
  showCancelButton: true,
  closeOnConfirm: false,
  animation: "slide-from-top",
  inputPlaceholder: 'Confirmation code',
  html: true,
}, function (inputValue) {
  if (inputValue === "") {
    swal.showInputError("Please enter confirmation code!");
    return false
  if (inputValue == ConfirmIput) {
    //Add your code here that should be executed after confirmation.
  else {
    swal.showInputError("Incorrect confirmation code!");
    return false


Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories