1

I have an address search area on my form in my asp.net mvc3 application. the whole form is submitted using the main submit button and the address search is initiated using the search button.

When the user submits the form using the search button only the house number and postcode fields need to be validated. When the user submits the whole form the whole form needs to be validated.

How is this achieved using fluentvalidation?

4

1 回答 1

0

这在 MVC 设计中不是一个理想的情况,但您仍然可以通过 jQuery 单击搜索按钮来实现此购买提交表单。使用单独的标识符来指定它是由搜索按钮还是由主按钮提交,方法是在模型本身或查询字符串中通过 jQuery 传递附加参数。在服务器端获得该标识符后,您可以使用自定义 fluentValidation 来验证具有 if..else 条件的模型。如果适合您的设计,您也可以使用 .ajax。

希望这可以帮助。

于 2011-10-06T13:16:29.577 回答