title: Optimizing JavaScript Code
body: <p>I have written the following JS, and it gets the job done, but I have been having a ton of trouble eliminating the repeating code. I keep breaking the functionality. </p>
  
  <p>It's just field validation using a <code>regex</code>, and adding an error message below the appropriate field if the input doesn't match the <code>regex</code>. It's works, but but I really want to begin writing more succinct code. </p>
  
  <p>If someone can help me do this, I can compare mine and yours and start understanding how to approach this type of task.</p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;form&gt;&lt;/form&gt;
  </code></pre>
  
  <p>Here's my JSFiddle code: <a href="https://jsfiddle.net/robinburrage/cnL2d4w8/2/" rel="nofollow">https://jsfiddle.net/robinburrage/cnL2d4w8/2/</a></p>