Parsley.js - Displaying Errors in a Specified Element

前端 未结 6 2011
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条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 08:32

    I returned true from the function provided with container key.

    My HTML Element

    
    
    

    Javascript

    $('#abc').parsley({
                errors: {
                    classHandler: function ( elem ) {}
                  , container: function ( elem, template, isRadioOrCheckbox ) {
                       //here i have span msg. id to be displayed as custom attribute in input element
                        $('#' + $(elem).attr('errorSpan')).html(template);
                        return true;//returning back boolean makes it work
                      }
                  , errorsWrapper: '
      ' , errorElem: '
    • ' } });

      It also works if I return

      return $('#' + $(elem).attr('errorSpan')).html(template);
      

      Hope this helps......

    提交回复
    热议问题