function validateFileUpload(obj) { var fileName = new String(); var fileExtension = new String(); // store the file name into the variable fileName = obj.value; // extract and store the file extension into another variable fileExtension = fileName.substr(fileName.length - 3, 3); // array of allowed file type extensions var validFileExtensions = new Array("jpg", "png", "gif", "jpeg", "tif", "tiff", "ico", "bmp"); var flag = false; // loop over the valid file extensions to compare them with uploaded file for (var index = 0; index < validFileExtensions.length; index++) { if (fileExtension.toLowerCase() == validFileExtensions[index].toString().toLowerCase()) { flag = true; } } // display the alert message box according to the flag value if (flag == false) { alert('Files with extension ".' + fileExtension.toUpperCase() + '" are not allowed.\n\nYou can upload the files with following extensions only:\n jpg, jpeg, bmp, ico, tif, tiff, png, gif\n'); return false; } else { return true; } }
if(characterCode == 13) { return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)