Index: audio.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio.module,v
retrieving revision 1.148
diff -u -p -r1.148 audio.module
--- audio.module	3 Oct 2008 06:41:17 -0000	1.148
+++ audio.module	13 Oct 2008 17:38:13 -0000
@@ -600,6 +600,8 @@ function _audio_file_delete($file) {
  * Implementation of hook_form().
  */
 function audio_form(&$node, &$form_state) {
+  drupal_add_js(drupal_get_path('module', 'audio') .'/audio.js');
+
   $type = node_get_types('type', $node);
   if ($type->has_title) {
     $form['title']['#weight'] = -5;
@@ -723,11 +725,13 @@ function audio_form(&$node, &$form_state
     );
   }
 
+  $extensions = implode(', ', array_filter(explode(' ', variable_get('audio_allowed_extensions', 'mp3 wav ogg'))));
   $form['audio']['audio_upload'] = array(
     '#tree' => FALSE,
     '#type' => 'file',
     '#title' => empty($node->audio['file']->filename) ? t('Add a new audio file') : t('Replace this with a new file'),
-    '#description' => t('Click "Browse..." to select an audio file to upload. Only files with the following extensions are allowed: %allowed-extensions.', array('%allowed-extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'<br />'
+    '#attributes' => array('accept' => $extensions),
+    '#description' => t('Click "Browse..." to select an audio file to upload. Only files with the following extensions are allowed: %allowed-extensions.', array('%allowed-extensions' => $extensions)) .'<br />'
       . t('<strong>NOTE:</strong> the current PHP configuration limits uploads to %maxsize.', array('%maxsize' => format_size(file_upload_max_size()))),
   );
   $form['audio']['downloadable'] = array(
Index: audio.js
===================================================================
RCS file: audio.js
diff -N audio.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ audio.js	13 Oct 2008 17:38:13 -0000
@@ -0,0 +1,29 @@
+// $Id: audio.js,v 1.9 2008/08/08 17:37:48 drewish Exp $
+
+/**
+ * Auto-attach standard client side file input validation.
+ */
+Drupal.behaviors.audioValidateAutoAttach = function(context) {
+  $("input[@type='file'][accept]", context).change( function() {
+    $('.audio-js-error').remove();
+
+    /**
+     * Add client side validation for extensions.
+     */
+    if (this.accept.length > 1) {
+      piped = this.accept.replace(/, /g, '|');
+      if (piped) {
+        v = new RegExp('\\.(' + piped + ')$', 'gi');
+        if (!v.test(this.value)) {
+          var error = Drupal.t("The selected file %filename cannot not be uploaded. Only files with the following extensions are allowed: %extensions.",
+            { '%filename' : this.value, '%extensions': this.accept }
+          );
+          // What do I prepend this to?
+          $(this).before('<div class="messages error audio-js-error">' + error + '</div>');
+          this.value = '';
+          return false;
+        }
+      }
+    }
+  });
+}
Index: images/audio_images.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/images/audio_images.module,v
retrieving revision 1.4
diff -u -p -r1.4 audio_images.module
--- images/audio_images.module	13 Oct 2008 16:27:56 -0000	1.4
+++ images/audio_images.module	13 Oct 2008 17:38:13 -0000
@@ -67,6 +67,8 @@ function audio_images_file_download($fil
 function audio_images_form_alter(&$form, &$form_state, $form_id) {
   // We only alter audio node edit forms with a file attached.
   if ($form_id == 'audio_node_form' && !empty($form['#node']->audio['file']->filepath)) {
+    drupal_add_js(drupal_get_path('module', 'audio') .'/audio.js');
+
     $form['#validate'][] = 'audio_images_node_form_validate';
 
     $form['audio_images'] = array(
@@ -104,6 +106,7 @@ function audio_images_form_alter(&$form,
       '#type' => 'file',
       '#title' => t('Add a new image'),
       '#tree' => FALSE,
+      '#attributes' => array('accept' => 'gif, jpg, jpeg, png'),
       '#description' => t('Click "Browse..." to select an image to add to this audio file. <strong>NOTE:</strong> Supported image types include GIF, JPG, and PNG.  Suggested dimensions: 170 X 170 pixels.'),
     );
   }
