title: How to determine whether a form is valid and display a popup window depdnding on whether is is valid or not?
body: <p>I'm trying to create a form where the user fills out their details, the form currently doesn't send if one of the fields has no input in it because I have added in a "required" into each of the tags to create the field. I have written some JavaScript to open a popup if the form is valid but it isn't working, the form submits to my PHP database but the pop up window doesn't appear. Any thoughts? Here is my current JavaScript. </p>
  
  <p>Code for the form fields -</p>
  
  <pre><code>label for="fname"&gt;First Name&lt;/label&gt;
      &lt;input type="text" id="fname" name="firstname" placeholder="Your name..." required&gt;
      &lt;label for="lname"&gt;Last Name&lt;/label&gt;
      &lt;input type="text" id="lname" name="lastname" placeholder="Your last name..." required&gt;
      &lt;label for="phonenumber"&gt;Phone Number&lt;/label&gt;
      &lt;input type="text" id="phonenumber" name="phonenumber" placeholder="The best number to contact you on..." required&gt;
  </code></pre>
  
  <p>Code to call the script -</p>
  
  <pre><code>&lt;button onclick="myFunction()"&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>JavaScript validation</p>
  
  <pre><code>&lt;script&gt;
  
  function validateForm() {
  var x = document.forms["fname"].value;
  var y = document.forms["lname"].value;
  var p = document.forms["phonenumber"].value;
  if ([x == "", y =="", p ==""]); {
   alert("Name must be filled out");
   return false;
  }
  } 
  
  function myFunction() {
  
  if (x == "") {
  return false;
  }
  else {
  alert("Thank you for making an enquiry, a member of our team will be in contact with you soon.");
  }
  } 
  </code></pre>
  
  <p></p>