diff -urpN HEAD/imagefield.js dev/imagefield.js
--- HEAD/imagefield.js	1970-01-01 10:00:00.000000000 +1000
+++ dev/imagefield.js	2008-05-13 11:11:33.000000000 +1000
@@ -0,0 +1,36 @@
+// $Id: imagefield.js,v 1.1.2.1 2008/04/21 06:59:13 dopry Exp $
+
+/**
+ *  Auto Attach standard client side file input validation
+ */
+Drupal.imagefieldValidateAutoAttach = function() {
+  $("input[@type='file'].imagefield").change( function() {
+    $('.imagefield-js-error').remove();
+    /**
+     *  add client side validation for the input[@file] accept attribute
+     */
+ 
+    if(this.accept.length>1){
+      v = new RegExp('\\.('+(this.accept?this.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" + this.accept.replace(/\|/g, ' ');
+        alert(error);
+        // what do I prepend this to? 
+        //$(this).prepend($('<div class="imagefield-js-error>"' + error + '</div>'));
+        this.value = ''; 
+        return false;
+      }   
+    }   
+    /**
+     * Add filesize validation where possible
+     */
+
+  }); 
+}
+
+// Global killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.imagefieldValidateAutoAttach);
+}
+
diff -urpN HEAD/imagefield.module dev/imagefield.module
--- HEAD/imagefield.module	2008-05-13 11:29:16.000000000 +1000
+++ dev/imagefield.module	2008-05-13 14:34:18.000000000 +1000
@@ -73,7 +73,7 @@ function imagefield_theme() {
  */
 function imagefield_elements() {
   $elements = array();
-  $elements['imagefield_widget_default'] =  array(
+  $elements['image'] =  array(
     '#input' => TRUE,
     '#columns' => array('fid', 'title', 'alt'),
     '#process' => array('imagefield_element_process'),
@@ -98,6 +98,11 @@ function imagefield_element_process($ele
     // Unset the storage to keep the form from unnecessarily rebuilding.
     unset($form_state['storage'][$fieldname]);
   }
+  // Change the type and theme to prevent FAPI from trying to output with the
+  // theme_image() function.
+  $element['#type'] = 'imagefield';
+  $element['#theme'] = 'imagefield';
+
   // Set an internal flag for requiredness. Prevents FAPI from interfering.
   $element['#image_required'] = $element['#required'];
   $element['#required'] = FALSE;
@@ -456,7 +461,7 @@ function imagefield_field($op, $node, $f
         }
         // Load the complete file if a filepath is not available.
         if (!empty($item['fid']) && empty($item['filepath'])) {
-          $items[$delta] = array_merge($item, _imagefield_file_load($item['fid']));
+          $items[$delta] = array_merge($item, field_file_load($item['fid']));
         }
         // Add nid so formatters can create a link to the node.
         $items[$delta]['nid'] = $node->nid;
@@ -498,7 +503,7 @@ function imagefield_file($op, $file) {
  */
 function imagefield_widget_info() {
   return array(
-    'imagefield_widget_default' => array(
+    'image' => array(
       'label' => t('Image'),
       'field types' => array('image'),
       'multiple values' => CONTENT_HANDLE_MODULE,
@@ -668,7 +673,7 @@ function theme_imagefield_formatter_imag
   $item = $element['#item'];
 
   if (empty($item['fid']) && $field['use_default_image']) $item = $field['default_image'];
-  if (empty($item['filepath']))  $item = array_merge($item, _imagefield_file_load($item['fid']));
+  if (empty($item['filepath']))  $item = array_merge($item, field_file_load($item['fid']));
   
   $class = 'imagefield imagefield-'. $field['field_name'];
   return  theme('imagefield_image', $item, $item['alt'], $item['title'], array('class' => $class));
@@ -698,7 +703,7 @@ function theme_imagefield_formatter_path
   $item = $element['#item'];
   if (empty($item['fid']) && $field['use_default_image'])  $item = $field['default_image'];
   // If there is no image on the database, use default.
-  if (empty($item['filepath']))  $item = array_merge($item, _imagefield_file_load($item['fid']));
+  if (empty($item['filepath']))  $item = array_merge($item, field_file_load($item['fid']));
 
   $attributes['class'] .= ' imagefield-formatter-path';
   return '<span '. drupal_attributes($attributes) .'>'. file_create_path($item['filepath']) .'</span>';
@@ -709,7 +714,7 @@ function theme_imagefield_formatter_url_
   $item = $element['#item'];
   if (empty($item['fid']) && $field['use_default_image'])  $item = $field['default_image'];
   // If there is no image on the database, use default.
-  if (empty($item['filepath']))  $item = array_merge($item, _imagefield_file_load($item['fid']));
+  if (empty($item['filepath']))  $item = array_merge($item, field_file_load($item['fid']));
 
   $attributes['class'] .= ' imagefield-formatter-url';
   return '<span '. drupal_attributes($attributes) .'>'. file_create_url($item['filepath']) .'</span>';
@@ -734,7 +739,7 @@ function theme_imagefield_row($element) 
 /**
  * FormAPI theme function. Theme the output of an image field.
  */
-function theme_imagefield_widget_default(&$element) {
+function theme_imagefield(&$element) {
   $output = '';
 
   // Always add tabledrag in case a table is created after uploads.
@@ -869,7 +874,7 @@ if (!function_exists('upload_file_downlo
  * Menu-callback for JavaScript-based uploads.
  */
 function imagefield_js($node_type, $fieldname) {
-  $field = content_fields($fieldname, $node_typ);
+  $field = content_fields($fieldname, $node_type);
 
   $form_state = array('values' => $_POST);
   $form_state['values'][$fieldname] = isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : array();
@@ -906,7 +911,6 @@ function imagefield_js($node_type, $fiel
   $output = theme('status_messages') . drupal_render($form_element);
 
   // We send the updated file attachments form.
-  drupal_set_header('Content-Type: application/json; charset=utf-8');
   print drupal_to_js(array('status' => true, 'data' => $output));
   exit;
 
