title: (JQuery/PHP) Validating data before submit
body: <p>What's the best approach for validating input (form) data right after it's typed?</p>
  
  <p>My idea is having a DIV right next to the input, this div is where we'll see a message saying whether data is valid or not, like:</p>
  
  <pre><code>Your name:
  &lt;input type="text"&gt;
  &lt;div id="data-validation"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  $("input").change(function(){
      $("#data-validation").load("data-validation.php?input="+$(this).val());
  });
  &lt;/script&gt;
  
  //data-validation.php
  &lt;?php
  $input = $_GET["input"];
  if(strlen($input) &lt; 3)
      echo "Name must have at least 3 characters.";
  ?&gt;
  </code></pre>
  
  <p>And PHP takes care of validating and displaying data.</p>
  
  <p>I'm afraid there's a much better way for doing this, I'd like to know what's the best way to do this.</p>