Parsley.js - Displaying Errors in a Specified Element

前端 未结 6 1981
Happy的楠姐
Happy的楠姐 2020-12-30 08:01

Using Parsley.js, is it possible to specify the element that should hold the error messages? I tried:

$(\'#myForm\').parsley({
    errors: {
        containe         


        
6条回答
  •  Happy的楠姐
    2020-12-30 08:35

    You'll need to use a callback function to do so

    Here a simple example to attach error messages to element parent for example.

    $('#myForm').parsley({
        errors: {
            container: function ( elem ) {
                return $( elem ).parent();
            }
        }
    });
    

    EDIT: Working on 1.1.10-dev, I changed the way to define the errors container like above. Careful, this is a BC Break;

提交回复
热议问题