<form>
<span id="fileinputplace"><input type="file" required="required" name="file_name" id="username" size="26" onChange="proverka(this)"</span>
</form>
<script>
function proverka(elem)
{
if (elem.value.match(/^[^\.]+\.doc(x)?$/i)) alert('true')
else
{
alert("error");
elem.value="";
}
}
</script>