English 中文(简体)
分类错误 安置
原标题:jquery errorPlacement

我有:

$("#pmtForm").validate({
            rules: {
                    acct_name: "required",                        
                    acct_type: "required",  
                    acct_routing:  { 
                                     required: true,    
                                     digits: true,
                                     exactLength:9
                                     }, 
                    acct_num:      { 
                                     required: true,    
                                     digits: true
                                     }, 
                    c_acct_routing:{ 
                                     equalTo:  #acct_routing 
                                     },     
                    c_acct_num:    { 
                                     equalTo:  #acct_routing 
                                     }      
            },
            messages: {
                    acct_name: "<li>Please enter an account name.</li>",
                    acct_type: "<li>Please choose an account type.</li>",
                    acct_routing: "<li>Please enter a routing number.</li>",
                    acct_num: "<li>Please enter an account number.</li>",
                    c_acct_routing: "<li>Please confirm the routing number.</li>",
                    c_acct_num: "<li>Please confirm the account number.</li>"
            },

        //  errorContainer:  #div.error ,

            errorPlacement: function(error, element) {
                $( #errorList ).html("");
                $( #errorList ).append(error);
                $( div.error ).attr("style","display:block;");  
            } 
        });

我正试图将错误信息插入上面的四点。 我的问题是,如果我删除这一条线:美元(#errorList .html(“”),那么它就第一次正确显示错误信息。 如果再一次打听,它将向四分五点发送另外一套信息。 如果我保留美元(#errorList .html(“”),那么我只收到一个错误信息。

  • Please enter an account number.
  • 我怎么再重犯错误,不重复,正确显示错误信息?

    预先感谢。

    最佳回答

    这项工作:

      $("#addPmtAcctForm").validate({
                rules: {
                        acct_name: "required",                        
                        acct_type: "required",  
                        acct_routing:  { 
                                         required: true,    
                                         digits: true,
                                         exactLength:9
                                         }, 
                        acct_num:      { 
                                         required: true,    
                                         digits: true
                                         }, 
                        c_acct_routing:{ 
                                         equalTo:  #acct_routing 
                                         },     
                        c_acct_num:    { 
                                         equalTo:  #acct_num 
                                         }      
                },
                messages: {
                        acct_name: "<li>Please enter an account name.</li>",
                        acct_type: "<li>Please choose an account type.</li>",
                        acct_routing: "<li>Please enter a routing number.</li>",
                        acct_num: "<li>Please enter an account number.</li>",
                        c_acct_routing: "<li>Please confirm the routing number.</li>",
                        c_acct_num: "<li>Please confirm the account number.</li>"
                },
    
                errorLabelContainer: $("ul", $( div.error )), wrapper:  li ,
    
                errorContainer: $( div.error ),
    
                errorPlacement: function(error, element) {
                    $( #errorList ).append(error);
                } 
            }); 
    
    问题回答

    j 质量验证将控制你错误信息的状况。 也就是说,你不得不使用:

    $( #errorList ).html("");
    

    用于控制你错误集装箱的状况。 在此情况下,你应当成为大韩民国,以便:

    errorContainer:  #div.error 
    

    减少错误更意在使你能够将错误信息传递给一个非常具体的集装箱(即:在为错误信息保留的与贸易有关的知识产权中的最后一个TD)。

    如果你使用PeBug类似的工具,你就会发现,j Query Validation将把错误信息贴在你错误的集装箱中,并根据某一表格是否穿过其规则控制其可见度。

    此外,你不必用超文本填写错误信息,你可以使用:

    wrapper: "li"
    

    I think you just need to add this to your validate method errorContainer: errorList errorLabelContainer: $("ol", container), wrapper: li ,

    ......





    相关问题
    getGridParam is not a function

    The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

    selected text in iframe

    How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

    jQuery cycle page with links

    I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

    jquery ui dialog opens only once

    I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

    jConfirm with this existing code

    I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

    Wrap text after particular symbol with jQuery

    What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

    热门标签