Forum Moderators: open
Ok new problem. In IE 7 only, when I do a lastindexof on a filepath, it returns the wrong one.
<!DOCTYPE html>
<html>
<head>
<title>lastIndexOf Test</title>
</head>
<body>
<script>
var filePath = "c:\\folder &\\file & stuff.pdf",
fileSeparator = "\\",
fileNameStart = filePath.lastIndexOf(fileSeparator), // 11
illegalChars = ['&', '%'],
isValid = true,
idx,
i,
n;
for (i = 0, n = illegalChars.length; i < n; i++) {
idx = filePath.lastIndexOf(illegalChars[i]);
if (idx > fileNameStart) {
isValid = false;
alert(idx)
break;
}
}
</script>
</body>
</html>