vivek
vivek

Reputation: 41

On click of esc button sweet alert should not be closed

when user clicks on esc alert should not be closed he should click on pay now button to move further.

 if($unpaid==true){
     echo $print = '<script>
      function alertOn(){
swal({ 
        title: "No Membership Fees Received",
        text: "Please pay membership fees as per your selected package",
        type: "warning",
        confirmButtonText: "PAY NOW"

      },
      function(){
        window.location.href = "unpaid.php";
    });
};
window.onload = alertOn
</script>';

Upvotes: 1

Views: 10623

Answers (3)

vivek
vivek

Reputation: 41

if ($unpaid == true) {
    echo $print1 = '<script>
    function alertOn(){
        swal({ 
            title: "No Membership Fees Received",
            text: "Please pay membership fees as per your selected package",
            type: "warning",
            confirmButtonText: "PAY NOW",
            **allowEscapeKey:false**

          },
          function(){
            window.location.href = "unpaid.php";
        });
    };
    window.onload = alertOn;
</script>';
}

Upvotes: 1

Newton Duarte
Newton Duarte

Reputation: 11

I think for this version you can use this:

swal({
  title: 'title',
  text: 'your text',
  button: false,
  closeOnClickOutside: false,
  closeOnEsc: false
});

Upvotes: 1

avi nash
avi nash

Reputation: 91

Yes, you can configure the swal function by modifying allowEscapeKey and allowOutsideClick properties to false like:

swal({
       title: 'title',
       text: 'your text',
       showConfirmButton: true,
       allowEscapeKey : false,
       allowOutsideClick: false
    });

Upvotes: 9

Related Questions