I need to press the button "submit" if the upload file format is valid. I have managed to check the format using the JavaScript below. My aim is between // and // ...
<script>
function Checkfiles(f){
f = f.elements;
if(/.*\.(gif)|(jpeg)|(jpg)|(doc)$/.test(f['filename'].value.toLowerCase()))
return true; + // and press the button submit //
alert('Please Upload Gif or Jpg Images, or Doc Files Only.');
f['filename'].focus();
return false;
};
</script>
And here's the HTML form:
<form action="something.php" method="post" name="myForm" onsubmit="return Checkfiles(this);">
<input type="file" name="filename" accept="/image*/">
<input type="submit" name="submit">
</form>
Thanks.