The accept attribute is not supported in Internet Explorer and Safari. That makes it pretty useless.
Code:
<input type = "file" id = "myfile" size = "50" onchange = "checkit()">
<script type = "text/javascript">
function checkit() {
var f = document.getElementById("myfile").value;
if (!/(gif)|(jpg)|(png)$/gi.test(f)) {
alert ("Invalid file type. Please try again");
return false;
}
}
</script>
A man generally has two reasons for doing things - the one that sounds good, and the real one. - J.P.Morgan