Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save sweet alert prompt in a js variable #80

Open
Scientist786 opened this issue Aug 16, 2018 · 1 comment
Open

How to save sweet alert prompt in a js variable #80

Scientist786 opened this issue Aug 16, 2018 · 1 comment

Comments

@Scientist786
Copy link

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", }, }, });

@rmogro
Copy link

rmogro commented Jun 14, 2019

The type input or prompt are the same, and to retrieve the input value, check this example:

swal({
  title: "An input!",
  text: "Write something interesting:",
  type: "input",
  showCancelButton: true,
  closeOnConfirm: false,
  inputPlaceholder: "Write something"
}, function (inputValue) {
  if (inputValue === false) return false;
  if (inputValue === "") {
    swal.showInputError("You need to write something!");
    return false
  }
  swal("Nice!", "You wrote: " + inputValue, "success");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants