title: How do I use JQuery Validation in ASP.NET MVC?
body: <p>I'm trying to use the JQuery Validation's "addClassRules" method in my ASP.NET MVC application.</p>
  
  <p>In my master page I'm including the following files...</p>
  
  <pre><code>    &lt;script src="&lt;%= Url.Content("~/Scripts/MicrosoftAjax.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="&lt;%= Url.Content("~/Scripts/MicrosoftMVCAjax.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="&lt;%= Url.Content("~/Scripts/MicrosoftMVCValidation.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;script src="&lt;%= Url.Content("~/Scripts/jquery-1.4.1.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="&lt;%= Url.Content("~/Scripts/jquery-validate.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I'm not sure which are actually required so I've added them all:)  Potential problem area?</p>
  
  <p>In my View I've got a simple textbox element which I'm trying to add the "required" validation via the Class attribute.  I've got dynamic forms and my end goal is to specify different validation rules in the Class attribute.  So for now I'm got something like this...</p>
  
  <pre><code>    &lt;%: Html.TextBoxFor(model =&gt; model.FieldEntry.Response.TextBoxValue, new { @class = "cRequired" } )%&gt;
  </code></pre>
  
  <p>then at the end of my View I'm including the following script which I though was suppose to hook up the Class name to a validation rule.</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt; 
  jQuery(document).ready( function()
  {
      jQuery.validator.addClassRules({
        cRequired: {
          required: true
        }
      });
  })
  &lt;/script&gt;
  </code></pre>
  
  <p>Seems like a straightforward example but the problem I am having is that I keep getting an error that <strong>jQuery.validator is null or not an object</strong>.  This refers to the first line of the the ready() function in the script above.</p>
  
  <p>Any help / suggestions?</p>