title: HTML. How to check If user entered text in form?
body: <p>So I have form with <em>First_Name</em>, <em>Last_Name</em>, <em>City</em> and <em>Email</em>. I need to check If fields are not empty.</p>
  
  <p>For now, after clicking submit It redirecting to <code>GetFbId.php</code> from here I have 5 values to insert to database: <em>FB_Id</em>, <em>First_Name</em>, <em>Last_Name</em>, <em>City</em> and <em>Email</em></p>
  
  <p><code>Form.html</code>          </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Registracija&lt;/title&gt;
      &lt;meta name="robots" content="noindex, nofollow"&gt;
  
      &lt;!-- include css file here--&gt;
     &lt;link rel="stylesheet" href="css/style.css"/&gt;
  
      &lt;!-- include JavaScript file here--&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/registration.js"&gt;&lt;/script&gt;
  
    &lt;/head&gt;   
    &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="main"&gt;
            &lt;form class="form"  method="post" action="#"&gt;
              &lt;h2&gt;Registracijos forma&lt;/h2&gt;&lt;hr/&gt;
              &lt;label&gt;First Name: &lt;/label&gt;
              &lt;input type="text" name="first_name" id="first_name" required&gt;
  
              &lt;label&gt;Last Name: &lt;/label&gt;
              &lt;input type="text" name="last_name" id="last_name" required&gt;
  
              &lt;label&gt;City: &lt;/label&gt;
              &lt;input type="text" name="city" id="city" required&gt;
  
              &lt;label&gt;Email: &lt;/label&gt;
              &lt;input type="text" name="email" id="email" required&gt;
  
              &lt;input type="submit" name="register" id="register" value="Register"&gt;
            &lt;/form&gt;   
          &lt;/div&gt;
     &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you see for now It have <code>action="GetFbId.php"</code>. I have JS script to check It, but It not working for me. JS is called: <code>registration.js</code></p>
  
  <p>I'm including in <code>Form.html</code>, inside <code>&lt;head&gt;</code> tags following:</p>
  
  <pre><code>    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/registration.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>And instead of <code>action="GetFbId.php"&gt;</code> I've tried to use <code>action="#"&gt;</code>, but in this case nothing happens after I click submit button.</p>
  
  <p><code>registration.js</code>* looks like:</p>
  
  <pre><code>$(document).ready(function(){
  
  $("#register").click(function(){
      var first_name = $("#first_name").val();
      var last_name = $("#last_name").val();
      var city = $("#city").val();
      var email = $("#email").val();
  
      if( first_name =='' || last_name =='' || email =='' || city =='')
          {
            alert("Fill all fields.");
          }   
      else if((first_name.length)&lt;3)
          {
              alert("Too short first name.");
          }
  
      else if((last_name.length)&lt;4)
          {
              alert("Too short last name.");
          }   
      else 
         {
           $.post("GetFbId.php",{first_name: first_name, last_name: last_name, city: city, email: email},
            function(data) {
             if(data=='Success')
             {
              $("form")[0].reset();
             }
             alert(data);
          });
         }
  
      });
  
  });
  </code></pre>
  
  <p>And in <code>GetFbId.php</code> I'm trying to get variables in following:</p>
  
  <pre><code>$first_name = $_POST['first_name']; 
  $last_name = $_POST['last_name']; 
  $city = $_POST['city']; 
  $email = $_POST['email']; 
  </code></pre>
  
  <p>But no action (nothing happens) when submit button is clicked. Have you ideas how to fix It?</p>