-1
  if (
  !document.getElementById("tousername").value.length == 0 &&
  !document.getElementById("fromusername").value.length == 0 &&
  !document.getElementById("frompassword").value.length == 0 &&
  !document.getElementById("subject").value.length == 0 &&
  !document.getElementById("message").value.length == 0 &&
  !data.username === undefined &&
  !data2.username === undefined) {
    alert("all good")
  }

I’m trying to test if all of the fields in the html web page is not empty, and if the 2 responses I get back from this API is not undefined. I want it to alert “all good” if these are all true. It just doesn’t work. Am I doing something wrong?

1 Answers1

0

data.username && data2.username could work as of your code is data.username is equals to undefiend which is not gonna happen when its coming from an api.

Toxy
  • 696
  • 5
  • 9