t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

How to prefill input text #769

Closed sarphu closed 6 years ago

sarphu commented 6 years ago

on pop up of swal. is there any method to prefill them, e.g. for editing a text

t4t5 commented 6 years ago
swal({
  content: {
    element: "input",
    attributes: {
      value: "pre-filled text",
    },
  },
});

See: https://sweetalert.js.org/docs/#content

Fredemb commented 2 years ago

@t4t5 s solution seems to work, except if it is never edited, in which case the swal returns an empty string, regardless of the pre-filled value