ASP.NET MVC 5를 사용하고 전자 메일의 유효성 검사를 수행해야합니다. EmailAddressAttribute는 어떻게 작동합니까?
I 다음 뷰 모델이 있습니다public class RegisterViewModel
{
[Required]
[Display(Name = "User name")]
[EmailAddress(ErrorMessage = "The email address is not valid")]
public string UserName { get; set; }
페이지 : "필요한"작품
@using (Html.BeginForm("AddUser", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Create a new account.</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.UserName)
</div>
</div>
검증을하지만 사용자 이름 텍스트 필드에 "즐 - 즐 - 즐 ~"를 입력 할 수 있습니다 유효성 검사기 "전자 메일"이 작동하지 않습니다. 서버 측에서도 동일한 문제, Model.IsValid = true. 왜, 어떻게 수정해야합니까?
참고는 매우 구체적이다 : _ "이 속성은 서버 측 이메일 확인 상당을 제공 JQuery와 유효성 검사, 따라서 같은 정규 표현식 공유에"_가. –