Model 这样写的
[Display(Name = "用户名")]
[Required(ErrorMessage = "请填写{0}")]
[StringLength(16, MinimumLength = 6, ErrorMessage = "{0}长度必须大于{2}位小于{1}位")]
[System.Web.Mvc.Remote("CheckSellerNick", "Login", ErrorMessage = "用户账号已存在")]
public string LoginNo { get; set; }
Controller 里面这样写的
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)] //清除缓存
public JsonResult CheckSellerNick(string LoginNo)
{
//bool exists = _userService.LoginNoExist(LoginNo);
bool exists = LoginNo.Equals("111111") ? true : false;
return Json(exists , JsonRequestBehavior.AllowGet);
}
View 这样写的
@Html.TextBoxFor(o => o.LoginNo, new { @class = "register_input", maxlength = "16", }) <div class="register_error">@Html.ValidationMessageFor(o => o.LoginNo)</div>
问题是:用户名是否重复这个问题一直提示不出来
在线等……