java script form submission conform popup box

For a simple form with an alert that asks if fields were filled out correctly or not.

sample HTML form

<form method="post">

<input type="text" name="input_name" >

<input type="submit" name="submit_name" onclick="confirm12(this.form)">


</form>

js code:

<script>

  function confirm12(form) {

    event.preventDefault();

 

    swal({

        title: "Are you sure?",

        text: "Are you sure you want to merge selected parts?",

        icon: "warning",

        buttons: true,

        dangerMode: true,

      })

      .then((willDelete) => {

        if (willDelete) {

     

          form.submit();

        }

      });

  }

</script>

Sign In or Register to comment.