Index: imagefield.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/Attic/imagefield.js,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 imagefield.js
--- imagefield.js	1 Aug 2008 18:02:16 -0000	1.1.2.2
+++ imagefield.js	3 Dec 2008 22:00:48 -0000
@@ -4,30 +4,31 @@
  *  Auto Attach standard client side file input validation
  */
 Drupal.imagefieldValidateAutoAttach = function() {
-  $("input[@type='file'].imagefield").change( function() {
-    $('.imagefield-js-error').remove();
+  $("input[@type='file']").change( function() {
+    // Remove any previous errors.
+    $('.file-upload-js-error').remove();
+
     /**
-     *  add client side validation for the input[@file] accept attribute
+     * Add client side validation for the input[@file] accept attribute.
      */
- 
-    if(this.accept.length>1){
-      accept = this.accept.replace(',','|');
-      v = new RegExp('\\.('+(accept?accept:'')+')$','gi');
+    var accept = this.accept.replace(/,\s*/g, '|');
+    if (accept.length > 1) {
+      var v = new RegExp('\\.(' + accept + ')$', 'gi');
       if (!v.test(this.value)) {
-        var error = 'The file ' + this.value + " is not supported.\n";
-        error += "Only the following file types are supported: \n" + accept.replace(/\|/g, ', ');
-        alert(error);
-        // what do I prepend this to? 
-        //$(this).prepend($('<div class="imagefield-js-error>"' + error + '</div>'));
-        this.value = ''; 
+        var error = 'The selected file ' + this.value + ' cannot not be uploaded. Only files with the following extensions are allowed: ' + accept.replace(/\|/g, ', ');
+
+        // What do I prepend this to?
+        $(this).before('<div class="messages error file-upload-js-error">' + error + '</div>');
+        this.value = '';
         return false;
-      }   
-    }   
+      }
+    }
+
     /**
-     * Add filesize validation where possible
+     * Add filesize validation where possible.
      */
-
-  }); 
+    /* @todo */
+  });
 }
 
 // Global killswitch
