title: ASP.NET form validation - highlight fields with JS/DHTML
body: <p>I have an issue that's been bugging me this morning. I'm building an ASP.NET webforms app that has many input forms and I'm trying to standardise how I manage validation. I would like to use the built-in validators (RequiredFieldValidator, Regex etc). My html requirements are:</p>
  
  <p>Before validation:</p>
  
  <pre><code>&lt;div class="formLine"&gt;
     &lt;label for="fieldID"&gt;Form Label&lt;/label&gt;
     &lt;input type="text" id="fieldID" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>After validation (in case of error):</p>
  
  <pre><code>&lt;div class="formLine formError"&gt;
  &lt;label for="fieldID"&gt;Form Label&lt;/label&gt;
  &lt;input type="text" id="fieldID" /&gt;
  &lt;span class="errorMessage"&gt;Please enter some value&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The additional <strong>span</strong> is fine, this is achieved with the ASP.NET validation controls. My problem is adding the <strong>formError</strong> class to the containing <code>&lt;div&gt;</code>.</p>
  
  <p>I'm comfortable using jQuery/DHTML to add this class, but just don't know where to hook it in. Is it possible to monitor DOM changes with jQuery - for example fire an event handler whenever a span is added as a child of <code>&lt;div class="formLine"&gt;</code>?</p>
  
  <p>Does anyone else have any good suggestions for dealing with this?</p>
  
  <p>Thanks for reading.</p>