title: ASP.NET MVC 3 How to validate dropdownlist
body: <p>I want to validate Date field of a birthday selection section. I have a dropdownlist with 1-31 days listed down and the default value is "0" and the text is "Day". Code is below:</p>
  
  <pre><code> public IEnumerable&lt;SelectListItems&gt; Date = new List&lt;SelectListItems&gt;
      {
          new SelectListItems{Value = "0", Text = "Day", Default = true},
          new SelectListItems{Value = "1", Text = "1"},
          new SelectListItems{Value = "2", Text = "2"},
          new SelectListItems{Value = "3", Text = "3"},
          new SelectListItems{Value = "4", Text = "4"},
          new SelectListItems{Value = "5", Text = "5"},
          new SelectListItems{Value = "6", Text = "6"},
          new SelectListItems{Value = "7", Text = "7"},
          new SelectListItems{Value = "8", Text = "8"},
          new SelectListItems{Value = "9", Text = "9"},
          new SelectListItems{Value = "10", Text = "10"},
          new SelectListItems{Value = "11", Text = "11"},
          new SelectListItems{Value = "12", Text = "12"},
          new SelectListItems{Value = "13", Text = "13"},
          new SelectListItems{Value = "14", Text = "14"},
          new SelectListItems{Value = "15", Text = "15"},
          new SelectListItems{Value = "16", Text = "16"},
          new SelectListItems{Value = "17", Text = "17"},
          new SelectListItems{Value = "18", Text = "18"},
          new SelectListItems{Value = "19", Text = "19"},
          new SelectListItems{Value = "20", Text = "20"},
          new SelectListItems{Value = "21", Text = "21"},
          new SelectListItems{Value = "22", Text = "22"},
          new SelectListItems{Value = "23", Text = "23"},
          new SelectListItems{Value = "24", Text = "24"},
          new SelectListItems{Value = "25", Text = "25"},
          new SelectListItems{Value = "26", Text = "26"},
          new SelectListItems{Value = "27", Text = "27"},
          new SelectListItems{Value = "28", Text = "28"},
          new SelectListItems{Value = "29", Text = "29"},
          new SelectListItems{Value = "30", Text = "30"},
          new SelectListItems{Value = "31", Text = "31"}
  
      };
  </code></pre>
  
  <p>My model is as below:</p>
  
  <pre><code> public class PaxInfoViewModel
  {
      public bool IsChild
      {
          get { return Age != null; }
      }
  
      [Required(ErrorMessage="Please select the born Month")]
      public int BirthYear1 { get; set; }
      [Range(2, 12, ErrorMessage="Please select the born Month")]
      public int BirthMonth { get; set; }
      [Required(ErrorMessage = "Please select the born Date")]
      [Range(2, int.MaxValue, ErrorMessage = "Please select the born Date")]
      public int BirthDate { get; set; }
  
  }
  </code></pre>
  
  <p>My View is as below:</p>
  
  <pre><code> &lt;div class="row"&gt;
                      &lt;div class="editor-label control-label"&gt;@Html.Label("Child " + i + " Birthday ")&lt;/div&gt;
                      &lt;div class="span1"&gt;@Html.DropDownListFor(m =&gt; Model.Rooms[roomCount - 1].Children[i - 1].BirthDate, new SelectList(Model.DropDown.Date, "Value", "Text"), new { @class = "mini" })&lt;/div&gt;
                      &lt;div class="span2"&gt;@Html.DropDownListFor(m =&gt; Model.Rooms[roomCount - 1].Children[i - 1].BirthMonth, new SelectList(Model.DropDown.Month, "Value", "Text"), new { @class = "small" })&lt;/div&gt;
                       &lt;div class="errorformat"&gt;@Html.ValidationMessageFor(m =&gt; Model.Rooms[roomCount - 1].Children[i - 1].BirthMonth)
                      @Html.ValidationMessageFor(m =&gt; Model.Rooms[roomCount - 1].Children[i - 1].BirthDate)
                   &lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>This Date is need to validate. User must select a value other than the Default value.  How can I do that.Please help.
  Thank You.</p>