Change location of jQuery validation plugin error message?

前端 未结 1 1069
我寻月下人不归
我寻月下人不归 2020-12-19 14:32

I am using the jQuery validation plugin and when I add the class required to the textboxes it validates the fields. However, the error message is shown after the text box an

相关标签:
1条回答
  • 2020-12-19 15:07

    Use errorPlacement. Example:

        $("#field-GeoLatlon").validate({
            rules: {
                "parameters[postcode]": {
                    isPostcode: true
                },
                "parameters[houseno]": {
                    startsWithNumber: true
                }
            },
            errorPlacement: errorPlacement
        });
    
    function errorPlacement(error, element)
    {
        var errorDD = $('<dd class="error"></dd>').insertAfter(element.parent('dd').next('dd'));
        error.appendTo(errorDD);
    }
    
    0 讨论(0)
提交回复
热议问题