title: How to validate .mp4, .mp3 and PDF file using javascript
body: <p>According to select option I need to upload pdf or mp3/mp4.</p>
  
  <p>If I select book or question paper, I need the validation to  only to upload pdf or doc file,</p>
  
  <p>If I select audio,  I should upload mp3 only.
  If I select video,  I should upload mp4 only.</p>
  
  <p>Please help me to do this validation using javascript. I need just condition . the rest will be done through backend </p>
  
  <pre><code>&lt;select id="upload_material" onchange="val()"&gt;
        &lt;option&gt;Select Material Type&lt;/option&gt;
        &lt;option value="1"&gt;Question Paper&lt;/option&gt;
        &lt;option value="2"&gt;Book&lt;/option&gt;
        &lt;option value="3"&gt;Audio/Video&lt;/option&gt;
  &lt;/select&gt;
  &lt;label class="myLabel"&gt;
       &lt;%= f.file_field :attachment, :onchange =&gt; "get_extension($this.value)" %&gt;
       &lt;!--  &lt;input type="file" style="margin-left:80px;" name="filetwo"&gt; --&gt;
       &lt;span&gt;Browse&lt;/span&gt;
  &lt;/label&gt;
  </code></pre>