Validation multiple input elements

New feature motivation

Using multiple form elements and custom inputs in swal is hard to do, especially if you want to validate them before closing the modal. You can create multiple input elements with a workaround, mentioned here: https://sweetalert2.github.io/#multiple-inputs
Validating them seems to be almost impossible or at least hard to do.

New feature description

I would like to see a possibility to add unlimited custom input elements and validate them. If not enough people are interested in this change, we could also use a function to validate before returning the values instead of a bigger refactor.

New feature implementation

It seems like this feature was already requested 2 years ago and demand is still here.
This PR already created this behaviour, but it got canceled.
There is even an example, how you could use in the code: Example


I think this feature would help people alot making forms faster, easier and more secure :).

2 thoughts on “Validation multiple input elements

  1. Hi, i dont know if this is pertinent to Say this here, but a two dans ago i releases a package entirely based on Sweetalert2 that that provides you highly customisable forms with multiples inputs, multi steps, validation including custom validatoion functions

    It IS basically a kind of wrapper i made for Sweetalert2, to create complexe forms

    Since this is exactly what you seems to be looking for, you can find it here :
    https://github.com/ChronicStone/sweetforms

    And this is a live examples of what u can do
    https://stackblitz.com/edit/sweetforms-multi-steps-example?file=index.js

    I plan to redo this in react to allow users to pass components as inputs ans control them in the future, but the current version already provides a lot of inputs types, and i’ll release sunday an update that will allow you to pass custom formatters to inputs and upgrade the grid système it is based on to allow you to map each line of inputs as you want.

    I also plan to add other features like cutom built-in input formats to handle more efficiently objects and arrays, like a “table” input, which will display a table with a checkbox for each row. This way you can select entire objects and will have more options to manage and edit your datas.

    By the way @limonte Sweetalert2 IS absolutely Amazing. It is just an incredible codebase to create tools like the one i made. The degrre of control you have on any aspect of the component lifecycle really juste blows my mind

  2. Wow this looks great. I’ll close this issue in a few hours if nobody comments anymore, since we’ll get a highly improved version of Swal. I’m looking forward to implement this in my application. If i find any bugs, i’ll let you guys know. 🎉

    @ChronicStone congratulations on your achivement. I think your Sweetforms looks very good and you should keep up the good work!