Input text in sweetAlert
Use Sweetalert2. There are numerous examples for input prompts to be found here, all of them using modern async/await constructs. If you want it the old way, try this:
Swal.fire({
title: "An input!",
text: "Write something interesting:",
input: 'text',
showCancelButton: true
}).then((result) => {
if (result.value) {
console.log("Result: " + result.value);
}
});
swal({
title: "An input!",
text: "Write something interesting:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: "Write something"
},
function(inputValue){
if (inputValue === null) return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false
}
swal("Nice!", "You wrote: " + inputValue, "success");
});
JSFiddle
Give the input
the autofocus
tag.
text: '<br /><form method="post" id="taxcode-update" name="taxcodeUpdate">'
+ '<input id="admin-tax-code" autofocus minlength="3" class="form-control wedding-input-text wizard-input-pad" type="text" name="taxCode" placeholder="Codice fiscale">'
+ '</form>',