【发布时间】:2012-04-09 09:50:37
【问题描述】:
我有一个视图模型
public class UserRegister
{
[Remote("CheckUserEmail")]
public string Email { get; set; }
}
有一个使用 UserRegister 模型强类型化的注册视图。
@Html.EditorFor(model => model.Email)
在用户控制器中我有动作注册
public ActionResult Register()
{
UserRegister userRegister = new UserRegister();
//// remote validation does not work on key press when the email field is not empty,
//// if i comment the below line or set the email as empty then remote validation works on keypress
userRegister.Email = "abc@abc.com";
return View(userRegister);
}
远程验证适用于未预先填充电子邮件的表单中的按键事件,但是当预先填充电子邮件字段时(以上代码),远程验证(按键事件)不起作用。这仅在焦点改变时有效。
有什么建议吗?
【问题讨论】:
标签: jquery asp.net-mvc jquery-validate remote-validation