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.
精彩评论