我是 MVC 技术的新手,我有一个 MVC 4 应用程序,正在尝试显示对选择输入(月份和年份)的验证。我对 input type="text" 进行了验证,它对我来说工作正常。我需要帮助来选择一个选项。请帮忙解决这个问题?
风景:
<li>
<div class="requiredField">@Html.LabelFor(m => m.AccountNumber)<span>* </span>
</div>
@Html.TextBoxFor(m => m.AccountNumber, new {@class ="requiredTextBox" })
<div class="swipeLink">
@Html.ActionLink("Swipe", "Swipe", "Transaction", new { @class = "swipePopupLink" })
</div>
</li>
<li>
<div class="requiredField">@Html.Label("Expiration Date")<span>* </span></div>
<div class="ExpirationMonthYear">
@Html.DropDownList("ExpirationMonth", new SelectList(Model.ExpirationMonth, "Value", "Text", 0), new { @class = "requiredTextBox" })
@Html.DropDownList("ExpirationYear", new SelectList(Model.ExpirationYear, "Value", "Text", 0), new { @class = "requiredTextBox" })
</div>
</li>
@Html.ValidationSummary()
<script src='@Url.Content("~/Scripts/jquery-1.6.2.js")' type="text/javascript">
</script>
<script src='@Url.Content("~/Scripts/jquery.validate.min.js")'
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"
type="text/javascript"></script>
模型视图:
[Required]
[Display(Name = "Account Number")]
public string AccountNumber { get; set; }
[Required]
[Display(Name = "Expiration Date")]
public IEnumerable<SelectListItem> ExpirationMonth { get; set; }
[Required]
public IEnumerable<SelectListItem> ExpirationYear { get; set; }
感谢您的支持