How can i write a function to validate if file uploaded is not in excel file format ".xls or .xlsx" it will prompt error message. Any help would be appreciated.
What i've tried so far. Below function will prompt error message too if read excel file in .xlsx format .
function verifyFile()
{
if(document.mainform.ATTACH_FILE.value.search(/\.(xls)$/) == -1) {
alert("Invalid filename extension!");
return false;
}
}
Expected result : accept both .xls
and .xlsx
format, prompt messsage if other than these format.