title: How to automatically add placeholder attribute to html input type number in mvc 4?
body: <p>This is a very specific issue. I managed to automatically add the placeholder attribute to html5 email input type by using an editor template called <code>EmailAddress.cshtml</code>, saved in <code>~/Views/Shared/EditorTemplates/</code> folder. See the code below:</p>
  
  <pre><code>@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "text-box single-line", placeholder = ViewData.ModelMetadata.Watermark })
  </code></pre>
  
  <p>It works because i'm using the <code>[DataType(DataType.EmailAddress)]</code> DataAnnotation in my view model.</p>
  
  <p>What doesn't works is when I use a <code>int?</code> variable.</p>
  
  <pre><code>public class MiageQuotaRequestViewModel
  {
      [Required]
      [DataType(DataType.EmailAddress)]
      [Display(Name = "Nombre de place demandées", Prompt = "Nombre de place")]
      [Range(0, 50, ErrorMessage = "La demande doit être comprise entre 0 et 50 places")]
      public int? RequestedQuota { get; set; }
  }
  </code></pre>
  
  <p><code>@Html.EditorFor</code> translates this input like this:</p>
  
  <pre><code>&lt;input class="text-box single-line" data-val="true" data-val-number="The field Nombre de place demandées must be a number." data-val-range="La demande doit être comprise entre 0 et 50 places" data-val-range-max="50" data-val-range-min="0" data-val-required="Le champ Nombre de place demandées est requis." id="RequestedQuota" name="RequestedQuota" type="number" value=""&gt;
  </code></pre>
  
  <p>The problem is that I can't display the <code>Prompt</code> DataAnnotation (usually translated by <code>placeholder</code>). Also, the <code>DataType</code> enum doesn't have any "number" or "integer" value that can allow me to use the EditorTemplate like I did for the EmailAddress DataType.</p>