innostudio / fileuploader

Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
141 stars 25 forks source link

frontend validation fails if user removes all async uploaded files #22

Closed SimJoSt closed 6 years ago

SimJoSt commented 6 years ago

Our input tag includes a required attribute. This makes it possible for frontend validation to fail, if no files have been added/uploaded. When using the async option and enabling start, the required attribute gets removed by the plugin after the first added/uploaded file. If this file/all files is/are removed by the user, the attribute does not get readded to the input tag, breaking the frontend validation.

Additionally, to make validators like https://github.com/1000hz/bootstrap-validator work reliably, the changed field (either setting the required attribute or changing the value) should be triggered with .trigger('change');

innostudio commented 6 years ago

@SimJoSt required attribute is not recommended to be used with the Fileuploader. The Plugin is cloning sometimes the input without required attribute to prevent other issues.

The best practice is to use API methods to get the number of files or to read the hidden Fileuploader's input.

SimJoSt commented 6 years ago

We currently have a quite simple validation in use and hoped for it to just work, by checking if the hidden Fileuploader's filled. That is most easily done, by setting the required attribute on the input. But we can make do without.