function ValidateFileUpload(sender, args)
{
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "";
var fl = document.getElementById('<%# FlpAttach.ClientID %>').value;
if (fl != "") {
var ext = document.getElementById('<%# FlpAttach.ClientID %>').value;
if (ext.length > 0) {
var str = ext.substring(ext.lastIndexOf('\\') + 1);
var sInvalidChars = "#%@&*:<>?\/{|}~";
var myIndex = 0;
args.IsValid = false;
var index = 0;
while (index < str.length) {
if (sInvalidChars.indexOf(str.charAt(index)) != -1) {
myIndex = myIndex + 1;
}
index++;
}
ext = ext.substring(ext.lastIndexOf('.') + 1);
ext = ext.toLowerCase();
if (ext != "doc" && ext != "docx" && ext != "pdf" && ext != "xls" && ext != "xlsx" && ext != "msg" && ext != "txt" && ext != "jpeg" && ext != "png" && ext != "rtf" && ext != "gif" && ext != "pptx" && ext != "ppt" && ext != "pps" && ext != "jpg" && ext != "xps" && ext != "eml") {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "Please upload valid file format (pdf/ppt/rtf/msg/doc/docx/xls/xlsx/jpeg/gif/png/txt/xps/pps/eml) only"
return args.IsValid = false;
}
else if (myIndex > 0) {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "Sorry, Invalid characters in filename(#%@&*:<>?\/{|}~).";
return args.IsValid = false;
}
else {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "";
return args.IsValid = true;
}
}
}
}
{
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "";
var fl = document.getElementById('<%# FlpAttach.ClientID %>').value;
if (fl != "") {
var ext = document.getElementById('<%# FlpAttach.ClientID %>').value;
if (ext.length > 0) {
var str = ext.substring(ext.lastIndexOf('\\') + 1);
var sInvalidChars = "#%@&*:<>?\/{|}~";
var myIndex = 0;
args.IsValid = false;
var index = 0;
while (index < str.length) {
if (sInvalidChars.indexOf(str.charAt(index)) != -1) {
myIndex = myIndex + 1;
}
index++;
}
ext = ext.substring(ext.lastIndexOf('.') + 1);
ext = ext.toLowerCase();
if (ext != "doc" && ext != "docx" && ext != "pdf" && ext != "xls" && ext != "xlsx" && ext != "msg" && ext != "txt" && ext != "jpeg" && ext != "png" && ext != "rtf" && ext != "gif" && ext != "pptx" && ext != "ppt" && ext != "pps" && ext != "jpg" && ext != "xps" && ext != "eml") {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "Please upload valid file format (pdf/ppt/rtf/msg/doc/docx/xls/xlsx/jpeg/gif/png/txt/xps/pps/eml) only"
return args.IsValid = false;
}
else if (myIndex > 0) {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "Sorry, Invalid characters in filename(#%@&*:<>?\/{|}~).";
return args.IsValid = false;
}
else {
document.getElementById('<%# cvFlpAttach.ClientID %>').innerHTML = "";
return args.IsValid = true;
}
}
}
}
No comments:
Post a Comment