In the example below, exactly the same code works in IE, Opera and FF when it is called from the HTML, but it fails in FF (only) when it is called as a function. What's going on?
thanks,
JAS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function filterKeys() {
if(event.keyCode){if ((event.keyCode > 32 && event.keyCode < 48) ||
(event.keyCode > 57 && event.keyCode < 65) ||
(event.keyCode > 90 && event.keyCode < 97)) {event.returnValue = false;}
}else{
if ((event.which > 32 && event.which < 48) ||
(event.which > 57 && event.which < 65) ||
(event.which > 90 && event.which < 97)) {return false;}
}
}
</script>
</head>
<body>
Filters: !@#$%^&* (works in both IE, Opera and FF)<br>
<br>
<textarea rows=2 cols=20 id="ta2" onKeypress="
if(event.keyCode){if ((event.keyCode > 32 && event.keyCode < 48) ||
(event.keyCode > 57 && event.keyCode < 65) ||
(event.keyCode > 90 && event.keyCode < 97)) {event.returnValue = false;}
}else{
if ((event.which > 32 && event.which < 48) ||
(event.which > 57 && event.which < 65) ||
(event.which > 90 && event.which < 97)) {return false;}
}
"></textarea><br>
<br>
Filters: !@#$%^&* (works in IE and Opera, but NOT FF!)<br>
<br>
<textarea rows=2 cols=20 id="ta1" onKeypress="filterKeys();">
</textarea>
<br>
</body>
<html>
thanks,
JAS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function filterKeys() {
if(event.keyCode){if ((event.keyCode > 32 && event.keyCode < 48) ||
(event.keyCode > 57 && event.keyCode < 65) ||
(event.keyCode > 90 && event.keyCode < 97)) {event.returnValue = false;}
}else{
if ((event.which > 32 && event.which < 48) ||
(event.which > 57 && event.which < 65) ||
(event.which > 90 && event.which < 97)) {return false;}
}
}
</script>
</head>
<body>
Filters: !@#$%^&* (works in both IE, Opera and FF)<br>
<br>
<textarea rows=2 cols=20 id="ta2" onKeypress="
if(event.keyCode){if ((event.keyCode > 32 && event.keyCode < 48) ||
(event.keyCode > 57 && event.keyCode < 65) ||
(event.keyCode > 90 && event.keyCode < 97)) {event.returnValue = false;}
}else{
if ((event.which > 32 && event.which < 48) ||
(event.which > 57 && event.which < 65) ||
(event.which > 90 && event.which < 97)) {return false;}
}
"></textarea><br>
<br>
Filters: !@#$%^&* (works in IE and Opera, but NOT FF!)<br>
<br>
<textarea rows=2 cols=20 id="ta1" onKeypress="filterKeys();">
</textarea>
<br>
</body>
<html>