To Validate the Filetype

Ppathi
Posted by Ppathi under JavaScript category on | Points: 40 | Views : 1245
This code will help to find file type, While upload the file and validate client on side

function validate1()
{
var File_Attach = document.getElementById("<%=File_Attach.ClientID%>").value;

if(File_Attach != "")
{
if((File_Attach.indexOf(".pdf") > 0) || (File_Attach.indexOf(".xls") > 0) || (File_Attach.indexOf(".zip") > 0) || (File_Attach.indexOf(".rar") > 0))
{
return true;
}
else
{
alert("only pdf,Excel,Zip,Winrar files are allowed");
return false;
}
}
}

Comments or Responses

Login to post response