Graeme Hackston
02-06-2003, 06:31 AM
I can't see what I'm doing wrong here. Why is the function finding matches to characters that aren't in the string?
Also, why can't I include characters like "+" and "(" in the array?
<html>
<head>
<title></title>
<script>
function Check_For_Valid_Path(Path) {
Char = new Array('!','@','&','%','^','#','$','|','{','}')
str = ''
for (var i=0;i<Char.length;i++) {
if (Path.match(Char[i])) {
alert(Path.indexOf(Char[i]))
str += Char[i]
}
}
alert(str)
}
test_str = 'string'
onload = function() {
Check_For_Valid_Path(test_str)
}
</script>
</head>
<body>
</body>
</html>
Also, why can't I include characters like "+" and "(" in the array?
<html>
<head>
<title></title>
<script>
function Check_For_Valid_Path(Path) {
Char = new Array('!','@','&','%','^','#','$','|','{','}')
str = ''
for (var i=0;i<Char.length;i++) {
if (Path.match(Char[i])) {
alert(Path.indexOf(Char[i]))
str += Char[i]
}
}
alert(str)
}
test_str = 'string'
onload = function() {
Check_For_Valid_Path(test_str)
}
</script>
</head>
<body>
</body>
</html>