繁体   English   中英

如何在弹出窗口中显示 jquery 验证错误消息?

[英]How to display the jquery validation error message in popup?

我想在弹出窗口中显示邮政编码字段错误消息。 不需要弹出的其他字段错误消息。我使用了以下代码。 这个怎么解决。

$(document).ready(function() {

$("#conference_form").validate({
   rules: {
        conpostcode:  {
            required: true,    
             minlength: 4, 
            remote: {
                url:"<?php echo base_url() ?>tools/check_postcode/1",
                type: "post",
              data:
                      {
                          postcode: function()
                          {
                              return $('#conpostcode').val();
                          }
                      },

            }           
          },
         name: "required",
         address: "required",
                   date: "required",
         description:"required",

    },
    messages: {
        conpostcode: "We don't have service this location, Please call us +44 12345454, for stock sets support.",
         name: "Please enter venu name",
         address: "Please enter address",
         date: "Please enter date",
         description: "Please enter description",


    }

})

});

如何仅在警报或弹出窗口中显示邮政编码错误消息。 请任何人帮助。

使用errorPlacement选项

errorPlacement(默认:将错误标签放置在无效元素之后) 类型:Function() 自定义创建的错误标签的放置。 第一个参数:作为 jQuery 对象创建的错误标签。 第二个参数:作为 jQuery 对象的无效元素。

    errorPlacement: function(error,element){ 
                        //error.insertAfter(element); 
                        //use error.html() as content in your popup div or simply
                        alert(error.html());             
                     }

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM