Q:

Can a form submit be disabled if a HTML file input field is empty?

In a form which contains only a
<input id="fileInput" name="BugReport" type="file" />

input field, I would like to disable the Submit button if the file input is empty (no file was chosen yet). Is there a recommended way to do this? 

A:

Add the required attribute to the input. It'll only work in browsers that support it, so you should have a JavaScript alternative (<form onSubmit="if(document.getElementById('fileinput').value == '') return false;"> or something along those lines).

