简体   繁体   中英

How to display the jquery validation error message in popup?

I want display the Postcode field error message in popup. Other fields error message not needed popup.I have used the below code. How solve this.

$(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",


    }

})

});

How display the postcode error message only in alert or popup. Please any one help.

Use errorPlacement option

errorPlacement (default: Places the error label after the invalid element) Type: Function() Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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