Parsley.js - Displaying Errors in a Specified Element

前端 未结 6 2010
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:39

    Just define classHandler function before Parsley library import, in my case, i'm using bootstrap and it's to apply error and valid classes on parent div (it has "form-group" class).

    
    

    Now just add data-parsley validate to your form tag :

    When using bootstrap, you need to specify bootstrap error and valid classes too

    
    

    In order to get the "has-error" class set on the parent div on invalid/error state (same for valid too):

    Example help text here.

    This solution global to all fields.

提交回复
热议问题