开发者

in mvc3 remote validate, how to fire the validate when the element looses focus?

I would like just to fire when the element looses focus, but cannot 开发者_运维百科figure how to do this. because each fired with key up is so waste resource.


If you use data annotations for validation, you can use the following in your model:

[Required]
[Display(Name="ArticleNumber")]
[Remote("Action", "Controller", HttpMethod="POST", ErrorMessage="ArticleNumber not found."]
public string ArticleNumber { get; set; }

In this case, the validation is triggered after losing the focus. The Remote-Attribute calls the action "Action" of the controller "Controller" with HTTP-POST.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜