title: SweetAlert2 : Validation required for one of the fields
body: <p>I am trying to perform validation on one of the fields in the form.</p>
  
  <p>Only if the value for that field exists will I be able to invoke the API, if not an error message will be thrown.</p>
  
  <p>I tried various examples from SweetAlert2's website. I just want the validation for one of the fields.</p>
  
  <pre><code>Swal.fire({
          title: 'Are you sure you want to Save the Notes?',
          type: 'info',
          showCancelButton: true,
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          confirmButtonText: 'Yes'
        }).then((result) =&gt; {
  
        console.log('result.value',result.value);
          if (result.value) {
            Swal.fire( {
              title: 'Download Notes',
                html:"&lt;div class='b'&gt;&lt;p&gt;ID&lt;/p&gt;&lt;/div&gt;&lt;input id='swal-input2' class='swal2-input' required/&gt;&lt;div class='b'&gt;&lt;p&gt;Notes&lt;/p&gt;&lt;/div&gt;&lt;input id='swal-input1' class='swal2-input' autofocus minlength='500' &gt;",
              confirmButtonText: 'Save',
              preConfirm: (login) =&gt; {
                console.log('document.getElementById(swal-input2).value',document.getElementById('swal-input2').value);
                request_string = {
          "Request":
            [
              {
                "Col1": "value1",
                "Col1": "value2",
                "Col1": document.getElementById('swal-input2').value,
                "Col1": document.getElementById('swal-input1').value,
  
              }
            ]
        };
               fetch('API_URL', {
          headers: {
            'Accept': 'application/json, text/plain, application/xml,  */*',
            'Content-Type': 'application/json',
            'Access-Control-Allow-Headers': 'Content-Type',
          },
          method: 'POST',
          body: JSON.stringify(request_string)
        }
        ).then(response =&gt; {
          if (response.status !== 200) {
  
            return;
          }
          response.text().then(data =&gt; {
  
            response_data = data;
            response_jsonObj = JSON.parse(response_data);
  
          });
        }).catch(error =&gt; this.setState({ error }));
    },
    allowOutsideClick: () =&gt; !Swal.isLoading()
  
              }).then((result) =&gt; {
                swal({
                title: " Your  request is being processed!",
                icon: "success",
                confirmButtonText: 'OK'
              }).then((okay) =&gt; {
                if (okay) {
                  history.push('/page1');
                  history.push('/page2');
                }
              });
              });
          }
        })
  </code></pre>