I have some javascript to validate an image name before upload. It ignores the file path and works correctly on IE and Chrome, but I get an incorrect file alert regardless when using this in firefox or safari.
function validate(elem){
var alphaExp = /^(?:[\w]\:|\|\\)(\\[a-zA-Z_0-9\-\.]+)+\.(jpg|jpeg|pjpeg|bmp|png|pdf|doc|docx|pub|pubx|id|psd|ai|eps|gif|tiff|zip|rar)$/;
if(elem.value.match(alphaExp)){
return true;
} else{
alert("File name or type is not suitable! \n\nPlease ensure the file type is one we accept and is named without spaces or special characters.");
elem.focus();
return false;
}
}