Hello,

It is not necessary to select file in a form. "If file has selected" It will check file extension. If it hasn't, it won't check.

Can you help for the code below?

PHP Code:
<script type="text/javascript">
    var 
filename document.getElementById("file").value;
    var 
result = ((/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined);
    if((
result == "jpg") || (result == "gif") || (result == "png")){

    }else{
        
alert("file extension is not allowed "+result);
    }
</script> 
Thanks in advance