I trying to prevent the uploading of files which include any character of ther than 1-9 and a-z ... but it isn't quite working.
function checkUploadString(str) {
checkStr = FilenameOnly(str);
var ValidString = "01234567890abcdefghilklmnop qrstuvABCDEFGHIJKLMNOPQRSTUVWXYZ";
var Ret = allowInString(checkStr, ValidString);
if (Ret = true){
alert("Sorry can't upload this file /n Please rename it using only letters a-z and 0-9");
return(false);
}
}
function allowInString (InString, RefString) {
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++) {
TempChar= InString.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1)
return (false);
}
return (true);
}
function FilenameOnly (InString) {
LastSlash=InString.lastIndexOf ('\\', InString.length-1)
OutString=InString.substring (LastSlash+1, InString.length)
return (OutString);
}
Where am I going wrong?
TIA
Away from the actual ... everything is virtual
function checkUploadString(str) {
checkStr = FilenameOnly(str);
var ValidString = "01234567890abcdefghilklmnop qrstuvABCDEFGHIJKLMNOPQRSTUVWXYZ";
var Ret = allowInString(checkStr, ValidString);
if (Ret = true){
alert("Sorry can't upload this file /n Please rename it using only letters a-z and 0-9");
return(false);
}
}
function allowInString (InString, RefString) {
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++) {
TempChar= InString.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1)
return (false);
}
return (true);
}
function FilenameOnly (InString) {
LastSlash=InString.lastIndexOf ('\\', InString.length-1)
OutString=InString.substring (LastSlash+1, InString.length)
return (OutString);
}
Where am I going wrong?
TIA
Away from the actual ... everything is virtual