preConfirm with inputValidator
See original GitHub issueIs it possible to use inputValidator
with preConfirm
? Looking at source code, it looks like inputValidator
only runs if there’s input
fields inserted using the default method but not if I’m inserting them using preConfirm
.
I suppose it would be nice to have a postConfirm
in this case?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How to use sweetalert2 preConfirm with httpRequest which ...
I have an Angular form component which sends a http request and subscribes to that request. ... For some reason, my swal.preConfirm doesn't...
Read more >Validation Message with a Custom Icon - SweetAlert2 example
Swal.fire({ title: 'Enter your name', input: 'text', customClass: { validationMessage: 'my-validation-message' }, preConfirm: (value) => { if (!value) ...
Read more >View Raw - UNPKG
(modalElement: HTMLElement) => void; /** * Determines whether given `inputValidator` and `preConfirm` functions should be expected to to signal * validation ...
Read more >sweetalert - Informática Instrumental - 9 - Passei Direto
inputValidator : sweetAlert. ... inputValidator === null) { var _inputValidator = function _inputValidator(url) { return new ... preConfirm) { sweetAlert.
Read more >SweetAlert2 - Translider Demenagement
Use it in combination with the preConfirm parameter. ... inputValidator, null, Validator for input field, should return Promise, see usage example.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As explained originally, the
inputValidator
is only used when the input is defined through theinput
property of swal. And it couldn’t be otherwise: if the input to the swal is defined throughhtml
, then swal doesn’t know which of the element(s) is to be considered an input.The only (and the correct) way to stop the swal promise to resolve (i.e. to execute the
then
block), is to use theshowValidationError()
. So this is the expected behavior. Please also note that this latter is deprecated and you should useshowValidationMessage()
instead.Does it answers your doubts?
Aha, sorry. The answer for your question is:
inputValidator
is working for swal2 input fields only (input
parameter).Inputs in the
html
parameter are totally custom andinputValidator
can’t do magic and validate whatever you provides in custom HTML code.