开发者

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

开发者 https://www.devze.com 2023-02-14 07:05 出处:网络
I would like just to fire when the element looses focus, but cannot 开发者_运维百科figure how to do this.

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

精彩评论

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