Asp MVC unobtrusive Client Validation always retur

2020-06-17 06:35发布

We have a partial view that contains a form with unobtrusive client validation enabled.

If we load the partial view using Html.Action, the validation works on the client side.

If when the user clicks a link we use JQuery to populate a div with the partial view , the client validation always returns true.

Any idea what is going on?

1条回答
狗以群分
2楼-- · 2020-06-17 06:58

You need to parse the new html to hook up the validation controls. You can do this using:

$.validator.unobtrusive.parse( $('.selector' ) );

where the selector returns the container holding the new HTML. This is what I use with tabbed interfaces.

查看更多
登录 后发表回答