Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 16, 2019 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/322dc176796194841dedd03f877c1e5c to your computer and use it in GitHub Desktop.
Save parzibyte/322dc176796194841dedd03f877c1e5c to your computer and use it in GitHub Desktop.
Swal
.fire({
title: "Tu nombre",
input: "text",
showCancelButton: true,
confirmButtonText: "Guardar",
cancelButtonText: "Cancelar",
inputValidator: nombre => {
// Si el valor es válido, debes regresar undefined. Si no, una cadena
if (!nombre) {
return "Por favor escribe tu nombre";
} else {
return undefined;
}
}
})
.then(resultado => {
if (resultado.value) {
let nombre = resultado.value;
console.log("Hola, " + nombre);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment