title: Validate Form Inputs on a good and reliable way
body: <p>On my page im working on, are a lot of input-forms.</p>
  
  <p>I want to check the user inputs before submit.</p>
  
  <p>Example</p>
  
  <p><strong>HTML/PHP</strong></p>
  
  <pre><code>&lt;input type="text" name="adress" id="adress"&gt;
  &lt;input type="text" name="amount" id="amount"&gt;
  </code></pre>
  
  <p>and actually im doing the following in Javascript</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function dataValidation() {
  error=false;
  var adress = document.getElementById('adress').value;
  var amount = document.getElementById('adress').value;
  if (adress == ""){
  error=true;
  }
  if (amount &gt;0 &amp;&amp; amount &lt; 999){
  }
  else {
  error=true;
  }
  if (error == false){
  document.forms["myForm"].submit();
  }
  }
  </code></pre>
  
  <p>So, basically this works fine for my, but the problem is, i have to create that function for every form, and add a IF for every field</p>
  
  <p>So, im looking for a better solution</p>
  
  <p>Idea 1 : Add a list, wich provides the types of input, like </p>
  
  <pre><code>adress = not empty,
  amount = &gt;0 &amp;&amp; &lt;999,
  </code></pre>
  
  <p>and then create a function, which checks all fields with that list</p>
  
  <p>Idea 2: Add a tag or something directly to the input field, what it should contain. and then create a function which checks all the fields</p>
  
  <p>Does somebody have a Idea how this can be done, and would like to help/advise me?</p>