简体   繁体   English

JQuery UI 选项卡、ASP .NET MVC 2 和客户端验证

[英]JQuery UI tabs, ASP .NET MVC 2 and client-side validation

I have JQuery tabs in my view.我的视图中有 JQuery 选项卡。 Each tab contain a partial view.每个选项卡都包含一个局部视图。 Some of them contain ajax forms with client-side validation.其中一些包含带有客户端验证的 ajax forms。 The problem is that validation works only when the tab is seleced at first time.问题是验证仅在第一次选择选项卡时才有效。 If I select another tab and then select previous tab then client-side validation does not work.如果我 select 另一个选项卡,然后 select 上一个选项卡,则客户端验证不起作用。 Maybe all necessary scripts are not being loaded at the second time?也许所有必要的脚本都没有在第二次加载? Or something else?或者是其他东西? Please, help me.请帮我。
I apologize for the lack of code.对于缺少代码,我深表歉意。 I did not post any code just because I have a whole bunch of JQuery UI wrappers and helpers in my project so it will be hard to understand how things are done.我没有发布任何代码只是因为我的项目中有一大堆 JQuery UI 包装器和帮助器,因此很难理解事情是如何完成的。 All those classes seem to work fine, except this bug I found.除了我发现的这个错误之外,所有这些类似乎都可以正常工作。 If something in this question is not clear then I will try to post some code and markup.如果此问题中的某些内容不清楚,那么我将尝试发布一些代码和标记。

Thanks in advance for your answers.提前感谢您的回答。

You may find the following blog post useful.您可能会发现以下博客文章很有用。 Basically the problem comes from the fact that dynamically added elements to the DOM need to be registered with client validation.基本上,问题来自这样一个事实,即动态添加到 DOM 的元素需要注册客户端验证。 This could be achieved using the Sys.Mvc.FormContext._Application_Load() method which could be invoked immediately after you inject the contents for the new tab after the AJAX call succeeds.这可以使用Sys.Mvc.FormContext._Application_Load()方法来实现,在 AJAX 调用成功后,您可以在注入新选项卡的内容后立即调用该方法。

You can also use jQuery validation plugin.您还可以使用 jQuery 验证插件。 Please go with below help documents:请 go 提供以下帮助文档:

http://docs.jquery.com/Plugins/validation http://docs.jquery.com/Plugins/validation

Manual validation gives lots flexibilities but it might take little bit more time.手动验证提供了很多灵活性,但可能需要更多时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP,NET -MVC5客户端验证不起作用 - ASP,NET -MVC5 client-side validation not working 针对 ASP.Net-MVC3 中的 object 的客户端验证? - Client-side validation against an object in ASP.Net-MVC3? 使用MvcContrib FluentHtml的ASP.NET MVC客户端验证 - ASP.NET MVC Client-side validation with MvcContrib FluentHtml ASP.NET MVC客户端验证的自定义属性 - ASP.NET MVC client-side validation of custom attribute ASP.NET MVC 2客户端验证触发错误 - ASP.NET MVC 2 client-side validation triggering incorrectly 具有3个选项卡的ASP.Net MVC 3客户端验证 - ASP.Net MVC 3 client side validation with a 3 tabs form 如何在 ASP.NET Core 3.1 MVC 中进行RequiredIf 客户端和服务器端验证? - How to make RequiredIf Client-side and server-side validation in ASP.NET Core 3.1 MVC? 自定义验证属性中的客户端验证 - asp.net mvc 4 - client-side validation in custom validation attribute - asp.net mvc 4 在 ASP.NET Core MVC 中不工作的 bool 字段的不显眼的客户端验证 - Unobtrusive client-side validation for bool field not working in ASP.NET Core MVC 如何使用客户端验证来处理 c# 中的 asp.net mvc? - How to use client-side validation to work on your asp.net mvc in c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM