function CheckFileExistence()
{
var filePath=document.getElementById('<%= this.filUpload.ClientID %>').value;
if(filePath.length<1)
{
alert("File Name Can not be empty");return false;
}
var validExtensions = new Array();var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
validExtensions[0] = 'jpg';
validExtensions[1] = 'jpeg';
validExtensions[2] = 'bmp';
validExtensions[3] = 'png';
validExtensions[4] = 'gif';
validExtensions[5] = 'tif'; validExtensions[6] = 'eps';
for(var i = 0; i < validExtensions.length; i++) {
if(ext == validExtensions[i])return true;
}
alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
return false;
}
use the function into button like OnClientClick="return CheckFileExistence()"
No comments:
Post a Comment