File Extension Javascript Validation

<script language=”javascript” type=”text/javascript”>
function chkFile()
{
var fextension = document.getElementById(“<%=FileUpload1.ClientID %>”).value;

var exten = fextension.split(“.”);
var len=exten.length;
//alert(exten.length);

if(exten[len-1]==”doc” || exten[len-1]==”docx”)
{
alert(“File upload successfully”);
return true;
}
else
{
alert(“Please select doc file”);
return false;
}
}
</script>

Share