How to display jqueryui validation error message in jqueryui tooltip

后端 未结 2 933
说谎
说谎 2020-12-21 11:40

I am following this tutorial to display validation errors in jqueryui tooltip. The validation works fine, but I am unable to display the correct error messages as the correc

2条回答
  •  星月不相逢
    2020-12-21 12:16

    Since the content() function is called on demand, you can supply whatever text you need based on the attributes of this which is the element in question.

    You need to inspect the element and return the text for the validation error that occurred. Something like:

    $(document).tooltip({
        items: ".input-validation-error",
        content: function () {
    
            //debugger;
            return $(this).attr('data-val-required') || 
                   $(this).attr('data-val-date') ||
                   $(this).attr('data-val-number'); // etc etc
        }
    });
    

    This will return the data validation attribute that is populated with an error message.

提交回复
热议问题