Usman Ahmad Khan
Usman Ahmad Khan

Reputation: 9

How to save sweet alert prompt in a js variable

I have this code

var pass = prompt("Please enter your password:", "");

I want to make this prompt through Sweet Alert and save it in variable pass. So far I have done this but I don't know how to save it in a variable.

swal({
content: {
element: "input",
attributes: {
 placeholder: "Type your password",
  type: "password",
},
},
});

Upvotes: 0

Views: 1317

Answers (1)

wobsoriano
wobsoriano

Reputation: 13462

You can do something like:

var pass = null;

swal({
    content: {
        element: "input",
        attributes: {
            placeholder: "Type your password",
            type: "password",
        }
    }
})
.then(function(value) {
    pass = value;
});

Upvotes: 1

Related Questions