如何在多个字段的基于DIV的选择表单元素上使用jQuery验证 [英] How to use jQuery Validate on DIV based select form element for more than one fields

查看:62
本文介绍了如何在多个字段的基于DIV的选择表单元素上使用jQuery验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提到了用于下拉框验证.如果我有多个下拉菜单,则只能在一个下拉菜单中正常工作

Hi i have referred this for the dropdown box validation. It's working fine for only one dropdown if i have more than one means it not showing correctly

$(document).ready(function () {
    $('.default').dropkick();
    $('.example_form').validate({
        highlight: function (element, errorClass) {         
            $(element).siblings('.dk_container').addClass('error');  
            $('.dk_toggle').css('border', 'none');
        },
        unhighlight: function(element, errorClass) {
            $(element).siblings('.dk_container').removeClass('error');  
            $('.dk_toggle').css('border', '1px solid #ccc');
        }
    });
});

这是小提琴

如何突出显示每个字段的错误

how would highlight the error for each field

推荐答案

尝试这个小提琴:

http://jsfiddle.net/yWANA/5/

现在已修复.

问题出在您编写的突出显示代码上.

The problem is with the highlight code you had written.

如果您在突出显示中写警报,您会发现它只会出现错误

If you write alert in highlight you will find it will come only for error

这是一些代码:

 $(document).ready(function () {
$('.default').dropkick();
$('.example_form').validate({
    highlight: function (element, errorClass) {   
         $(element).prev().addClass('error');
         //$(element).prev().addClass('error'); 
         $('.dk_toggle').css('border', 'none');
    },
    unhighlight: function(element, errorClass) {
        $(element).prev('.dk_container').removeClass('error');  
        $('.dk_toggle').css('border', '1px solid #ccc');
    }
});

});

这篇关于如何在多个字段的基于DIV的选择表单元素上使用jQuery验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆