Validation in file.js doesn´t work correctly

Created on 9 June 2016, over 8 years ago
Updated 18 October 2023, 12 months ago

This is a bug which happens when validating the file extension on the file input and both cases are related.

  1. The div outside the input file has the same id as the "-upload" input file, then file.js throws an error "this.value" is undefined, as validateExtension is pointing to its parent div, and therefore it hasn't got any value tag.
  2. When a user submits a file using the field, the user removes the uploaded file and tries to upload a wrong extension file, the second validation never happens as the file field attaches twice the validation in $(selector, context).bind('change', {extensions: extensions}, Drupal.file.validateExtension); (removing the text from the previous validation) This may be solved as in https://www.drupal.org/node/2593147#comment-10452571

The process to test if everything works as expected is to create a new file upload item with some extensions to validate, once you've choosen the file if the validation works as expected it should show the error:
Drupal.t("The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions." ....

Try to upload an image with the right extension, hit the remove button, try again to upload an image with the wrong extension, does the validation work again?

🐛 Bug report
Status

Closed: outdated

Version

7.0 ⚰️

Component
Javascript 

Last updated 5 days ago

Created by

🇪🇸Spain radabass

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024