title: Sweetalert2 doesn't return true/false
body: <p>I'm trying to work with the SweetAlert2. It works, when I don't want to send some data through $_POST. But when I want to send data through $_POST, the sweetalert just appears on less then one second, then disappers and regardless of user choice the form is send.</p>
  
  <p>How can I modify my code, when I'd like to have a regular window-confirmation and when the user click on "delete", the form will be send, otherways when he click on "cancel", the form will be not send?</p>
  
  <pre><code>if(isset($_POST['submit'])) {  
    echo 'Your form was submitted.';
  }
  
  &lt;form action="#" method="post&gt;                
   &lt;label&gt;
     &lt;span&gt;Username&lt;/span&gt;
     &lt;input type="text" value="" name="username" /&gt;
   &lt;/label&gt;
   &lt;input type="submit" name="submit" value="Register!" id="test-1" /&gt;    
  &lt;/label&gt;     
  &lt;/form&gt;
  
  
  
  &lt;script&gt;
   document.querySelector('#test-1').onclick = function(){
    swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes, delete it!'
    }).then(function () {
      swal(
        'Deleted!',
        'Your file has been deleted.',
        'success'
        )
    })
  
       //IF SWAL =&gt; DELETE -&gt; send form
       //ELSE IF SWAL =&gt; CANCEL -&gt; do nothing 
       //when I put here "return false;", then sweetalert is working, but it doesn't send the form
  &lt;/script&gt;
  </code></pre>
  
  <h1>Solution thanks to Novice:</h1>
  
  <pre><code>&lt;?php if(isset($_POST['send']))
  {echo 'Your form was submitted.';} ?&gt;
  
  &lt;form id='myfrm' action="#" method="post"&gt;   
   &lt;label&gt;
     &lt;span&gt;Username&lt;/span&gt;
     &lt;input type="text" value="" name="username" /&gt;
     &lt;input type="hidden" name="send" value="send"&gt;
   &lt;/label&gt;
  &lt;/form&gt;
   &lt;button value="Register!" id="test-1"&gt; submit &lt;/button&gt;
  
  &lt;script&gt;
  document.querySelector("#test-1").onclick = function(){
    swal({
      title: "Are you sure?",
      text: "You won't be able to revert this!",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#3085d6",
      cancelButtonColor: "#d33",
      confirmButtonText: "Yes, delete it!"
    }).then(function () {
     document.querySelector("#myfrm").submit();    
    })
  }      
  &lt;/script&gt;
  </code></pre>