question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Input Field Validation

See original GitHub issue

This may be a stupid question but how do you add validation for multiple html fields to check if they are empty before submitting? I can retrieve the values of the fields but they need validation.

        title: 'Details',
        html:
            '<p style="float: left;" autofocus>Name:</p>' +
            '<input id="swal-input1" class="swal2-input">' +
            '<p style="float: left;">Email:</p>' +
            '<input id="swal-input2" class="swal2-input">' +
            '<p style="float: left;">Description:</p>'+
            '<input id="swal-input3" class="swal2-input">' +
            '<p style="float: left;">Notes:</p>' +
            '<input id="swal-input4" class="swal2-input">',

        preConfirm: function () {
            return new Promise(function (resolve) {
                resolve([
                    $('#swal-input1').val(),
                    $('#swal-input2').val(),
                    $('#swal-input3').val(),
                    $('#swal-input4').val()
                ])
            })
        }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
gvernicommented, Apr 16, 2019

@jesusaugusto0x2 @nhpm have a look to this example. Here we are validating that both username and password are not empty. You can replace that with whatever check you want to implement. The code for the example can be found here

6reactions
limontecommented, Mar 15, 2018

Validation of multiple fields isn’t supported, you should implement it by yourself depending on your project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validating multiple fields in a form - javascript - Stack Overflow
I was doing the testing for the first time. I read the this code and made one of my own from it. The...
Read more >
Validating multiple inputs as one - FormValidation
In some cases, you need to validate a value which is combined by various fields. For instance, a Birthday field might be a...
Read more >
How to validate if input in input field is divisible by or multiple ...
How to validate if input in input field is divisible by or multiple of a number using express-validator ?
Read more >
Input Validation with Regex and Multiple sections with Pure ...
I have made validations but without using Regex and multiple sections I want it to make it for my own, and finally I...
Read more >
Multiple form validation with one function - JavaScript - SitePoint
Form submission is performed through the form element, with the onsubmit attribute being used to validate the form. If the called script returns ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found