22

I want to change the 'Ok' button with 'Select patient' and the 'Cancel' to 'Speed case'. How can I do that?

swal({
  text: "Start new case by",
  buttons: true,
  confirmButtonText: "Select Patient?",
  cancelButtonText: "Speed Case?",      
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Dip Girase
  • 439
  • 1
  • 7
  • 18
  • 2
    The `confirmButtonText` and `cancelButtonText` properties are exactly what you need. You just need to add a `title` property for the alert to appear: https://jsfiddle.net/hfev385s/ – Rory McCrossan Feb 28 '18 at 10:21
  • because i am creating two button , this both button redirect to different page sir – Dip Girase Feb 28 '18 at 10:30

4 Answers4

29

here is the answer

 swal({
            title: "Are you sure?",
            text: "you want to Cancel Operation!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#DD6B55',
            confirmButtonText: 'Yes, I am sure!',
            cancelButtonText: "No, cancel it!",
            closeOnConfirm: false,
            closeOnCancel: false
        },

hope it will work for you

17
swal({
  text: "Start new case by",
  buttons: ["Select Patient?", "Speed Case?"],
});
RohitIUC
  • 261
  • 2
  • 11
  • 3
    This does not work for me, perhaps because there are multiple forks of sweet-alert named the same (or almost the same) thing: sweetalert2. And perhaps some people are still using version 1, which _might_ also have multiple forks... I don't know. If this doesn't work for you either, try [this one](https://stackoverflow.com/a/49027425/241142), that's what worked for me. – iconoclast Jan 16 '19 at 00:34
8

You can use this approach

swal({
  text: "Start new case by",
  showCancelButton: true,
  confirmButtonText: "Select Patient?",
  cancelButtonText: "Speed Case?",     
  title: 'Title'
});

1
swal({
    title: 'Are you sure?',
    text: 'Once deleted, you will not be able to recover this imaginary file!',
    icon: 'warning',
    buttons: true,
    dangerMode: true,
    buttons: ['yes, forsure', 'no, thanks']
});
Yamen Ashraf
  • 2,637
  • 2
  • 20
  • 26