且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用取决于jQuery Validation插件

更新时间:2023-01-16 14:25:24

使用忽略选项( http://docs.jquery.com/Plugins /验证/验证#toptions )可能是您处理此问题的最简单方法。取决于您在表单上还有什么。例如,如果您有其他已禁用的控件但仍需要根据某些原因进行验证,则不会对禁用的项目进行过滤。但是,如果该路由不起作用,则使用其他类进行过滤(使用复选框添加和删除)可以使您到达目的地,但更容易。

Using the "ignore" option (http://docs.jquery.com/Plugins/Validation/validate#toptions) might be the easiest way for you to deal with this. Depends on what else you have on the form. For i.e. you wouldn't filter on disabled items if you had other controls that were disabled but you still needed to validate for some reason. However, if that route doesn't work, using an additional class to filter on (adding and removing with your checkboxes) should get you to where you want to go, but easier.

        $('form').validate({
            ignore: ":disabled",
            ...
        });