-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minFileCount validation doesn't work properly when more than one input field in the same form #875
Comments
You seem to be combining both modes (ajax submission and form submission) which is strictly NOT SUPPOSED TO BE DONE as highlighted in the USAGE modes of the plugin. Do not provide any uploadUrl if you are uploading via form submit. I am not clear on the other part of your query... can you summarize the issue? |
@kartik-v |
Hello @kartik-v I am getting the same issue that @xqxian reported. Basically, if I define more than one input-file inside the same html-form (Form Submission Mode), the plugin only validates the last one in the form. I used the example page included in the download *.zip
Thank you in advance. |
Will provide a fix soon |
* 'master' of https://github.com/kartik-v/bootstrap-fileinput: (269 commits) Ensure events are namespaced correctly Update message for single file upload Updates to release v4.3.9 fixes kartik-v#863 fixes kartik-v#887 Updates to release v4.3.9 fixes kartik-v#875 fixes kartik-v#885 fixes kartik-v#886 Updates to release v4.3.9 Fix kartik-v#882: Correct image resize validation Update es.js Updates to release v4.3.8 Updates to locales Added Russian translation for msgUploadEmpty Fix kartik-v#874: Enhance/Standardize CSS Styles for Krajee Default Theme Fix noFilesSelected in es.js Fix kartik-v#872: Correct typo in `bootstrap.min.css` Updates to release v4.3.8 Fix kartik-v#870: Correct config.width parsing Update to release v4.3.7 Updates to release v4.3.7 Updates to release v4.3.7 Updates to release v4.3.7 Correct function typo ...
Prerequisites
master
branch of bootstrap-fileinput.Steps to reproduce the issue
First of all thanks for your great plugin! But I've met some validation problems in Form Submission Mode when I tried setting minFileCount(or data-min-file-count) in a form containing more than one input field. Briefly speaking only the last input field will be validated properly. For example, assume that I want the first input to upload at least 2 files, and the second one at least 1 file, so I organized my code like this:
Then I selected 1 file in the first input and 1 file in the second one and submitted the form. The submission was supposed to be failed and show an error message since there was only 1 file selected in the first input, which was unexpected . However, the submission hasn't been aborted in this case, which meant the min-file validation of the first input hasn't been triggered, but may worked properly in the second input.
To confirm my guess I made a slight change, this time the second input must upload at least 2 files, and the first one only 1 file, just like the following:
Then as in the first case, I selected 1 file in the first input and 1 file in the second one and submitted the form. This time the validation finally worked to abort the submission, and showed me an error message that "You must select at least 2 files to upload", which proved that only the last input field would be validated properly.
Due to the specifics of my project I don't want the users to upload individual file so the Ajax Submission Mode doesn't seem to suitable for me... Actually I did try the Ajax Mode and change my code to this:
As in the above cases I selected 1 file in the first input and 1 file in the second one then clicked the submit button, but the file-count validation of both input didn't seem to be triggered and the form just been submitted directly. Only the default "Upload" button in each input field could trigger the validation properly. So I think the Form Submission Mode is still a better choice for me(?).
Hope you can recreate the problem and fix this bug, thanks!
PS: What about triggering the minFileCount validation when the files are selected from Browse button? Just as the maxFileCount validation does.
Best regards! : )
Environment
Browsers
Operating System
Libraries
The text was updated successfully, but these errors were encountered: