2015-12-14 138 views
2

我想输出表单验证错误,当您将鼠标悬停在Dropzone的Dropoff文件中的“X”时。DropzoneJS&Laravel - 输出表单验证错误

我得到什么:

enter image description here

我怎样才能让object Object输出表单验证实际的错误信息?我可以提醒错误消息,但实际上不能在悬停在x上时显示错误消息。

我的js文件:

Dropzone.options.fileupload = { 
    maxFilesize: 20, 

    init: function() { 
     thisDropzone = this; 
     this.on("error", function (file, responseText) { 

       $.each(responseText, function (index, value) { 
        alert(value); //this shows the alert of the error message 

       }); 


     }); 
    } 
}; 

我的控制器:

$this->validate($request, [ 
     'file' => 'max:20000', 
    ]); 

回答

0

我有固定我的问题。

给任何人可能有同样的问题。

Dropzone.options.fileupload = { 
maxFilesize: 50, 
init: function() { 
    thisDropzone = this; 
    this.on("error", function (file, responseText) { 
     $.each(responseText, function (index, value) { 
      $('.dz-error-message').text(value); 
     }); 
    }); 
} 
}; 

我简单地把$('.dz-error-message').text(value);

的完整代码固定它