title: ASP.NET MVC data-val attribute for unobtrusive validation not present
body: <p>I am struggling for hours trying to understand WHY my rendered input elements within form DON'T include the data-val attributes anymore.
  The environment is MVC 5 and .net framework 4.5 (I upgraded from MVC 4 hoping to solve the problem!)</p>
  
  <p>An example of one of the fields being rendered:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;input id="UserName" class="text-box single-line" type="text" value="" name="UserName"&gt;
  &lt;/input&gt;
  &lt;span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="UserName"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>my model:</p>
  
  <pre><code> public class AccountRegistrationValidation
      {
      [Key]
      public int ID { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [System.Web.Mvc.Remote("UsernameInUse", "Account", HttpMethod = "POST",
              ErrorMessageResourceType = typeof(ValidationStrings), ErrorMessageResourceName = "UsernameExists")]
      public string UserName { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [StringLength(20, ErrorMessageResourceName = "PasswordMinLength", ErrorMessageResourceType = typeof(ValidationStrings), MinimumLength = 6)]
      [DataType(DataType.Password)]
      public string Password { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [DataType(DataType.Password)]
      [System.Web.Mvc.Compare("Password", ErrorMessageResourceName = "PasswordsMustMatch", ErrorMessageResourceType = typeof(ValidationStrings))]
      public string ConfirmPassword { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [DataType(DataType.EmailAddress)]
      [System.Web.Mvc.Remote("EmailInUse", "Account", HttpMethod = "POST", ErrorMessage = "Email address already exists. Please enter a different address.")]
      public string Email { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [DataType(DataType.Text)]
      public string FirstName { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
      [DataType(DataType.Text)]
      public string LastName { get; set; }
      }
  </code></pre>
  
  <p>The View Form:</p>
  
  <pre><code>@model Test.Models.AccountRegistrationValidation
  @using CaptchaMvc.HtmlHelpers
  @{
      ViewBag.Title = ViewRes.RegisterStrings.RegisterTitle;
  
  }
  
  
  
  &lt;div class="container"&gt;
  &lt;div class="row-fluid"&gt;
      &lt;div class="span12"&gt;
          &lt;div class="page-header"&gt;
              &lt;h1&gt;@ViewBag.Title &lt;br /&gt;&lt;small&gt;@ViewRes.RegisterStrings.RegisterSubTitle&lt;/small&gt;&lt;/h1&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-fluid"&gt;
      &lt;div class="span7"&gt;
  
  
  @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal" }))
  {
      @Html.AntiForgeryToken()
     @Html.ValidationSummary()
  
      &lt;fieldset&gt;
          &lt;legend&gt;@ViewRes.RegisterStrings.FillInFields&lt;/legend&gt;
  
         &lt;div&gt;
              &lt;p class="text-info"&gt;&lt;i&gt;@ViewRes.RegisterStrings.ALL_FIELDS_REQ&lt;/i&gt;&lt;/p&gt;
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt; 
              @Html.LabelFor(m =&gt; m.FirstName, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.TextBoxFor(m =&gt; m.FirstName)
              &lt;/div&gt;
              @Html.ValidationMessageFor(m =&gt; m.FirstName)
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt;
              @Html.LabelFor(m =&gt; m.LastName, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.TextBoxFor(m =&gt; m.LastName)
  
              &lt;/div&gt;
              @Html.ValidationMessageFor(m =&gt; m.LastName)
          &lt;/div&gt; 
  
          &lt;div class="control-group"&gt;
              @Html.LabelFor(m =&gt; m.UserName, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.EditorFor(m =&gt; m.UserName)
                    @Html.ValidationMessageFor(m =&gt; m.UserName)
              &lt;/div&gt;
  
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt;
              @Html.LabelFor(m =&gt; m.Password, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.PasswordFor(m =&gt; m.Password)
  
              &lt;/div&gt;
              @Html.ValidationMessageFor(m =&gt; m.Password)
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt;
              @Html.LabelFor(m =&gt; m.ConfirmPassword, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.PasswordFor(m =&gt; m.ConfirmPassword)
  
              &lt;/div&gt;
              @Html.ValidationMessageFor(m =&gt; m.ConfirmPassword)
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt;
              @Html.LabelFor(m =&gt; m.Email, new { @class = "control-label" })
              &lt;div class="controls"&gt;
                  @Html.TextBoxFor(m =&gt; m.Email)
  
              &lt;/div&gt;
              @Html.ValidationMessageFor(m =&gt; m.Email)
          &lt;/div&gt; 
  
  
          &lt;div class="control-group"&gt; 
              &lt;label class="control-label" for="Input"&gt;@ViewRes.RegisterStrings.SEC_CONTROL&lt;/label&gt;
              &lt;div class="controls"&gt;
                  @Html.Captcha(ViewRes.RegisterStrings.REFRESH_CAPTCHA, "Input", 5, "Is required field.")
              &lt;/div&gt;
          &lt;/div&gt;
  
  
          &lt;div class="control-group"&gt; 
              &lt;div class="controls"&gt;
                  &lt;input type="submit" value="@ViewRes.RegisterStrings.ButRegister" class="btn btn-success btn-large" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;  
      &lt;/fieldset&gt;
  }
  
      &lt;/div&gt;
      &lt;div class="span1"&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;div class="row"&gt;
      &lt;div class="span12"&gt;
          &lt;div class="muted"&gt;&lt;small&gt;@Html.Raw(ViewRes.RegisterStrings.IntroTermsService)&lt;/small&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  
  
  @section Scripts
  {
  
      @Scripts.Render("~/bundles/jqueryval")
  
  }
  </code></pre>
  
  <p>My View includes all the necessary js files (jquery.validate and jquery.validate.unobtrusive)</p>
  
  <p>Any ideas?!?</p>