Firefox: Filter Extended Ascii from Form

  • Thread starter news.la.sbcglobal.net
  • Start date
N

news.la.sbcglobal.net

I've tried about 300 iterrations of this same ability, and none of them seem
to work in Firefox. Take the following code for example. It WILL stop me
from entering zero into the first text box, but it wont stop me from
entering extended ascii characters (which is the final goal).

Two items of note:
1) Typing ALT+0156 inputs "o". And strangely enough the statusbar text gets
set to "ALT0moz2 ALT0moz2 ALT0moz2". Only 3 ALT sequences show up when I
actually type 4 characters
2)Im working on a laptop that has no true numpad, so the '0' may be a result
of me having to hold down a special function key in order to enable a numpad
overlay.). So the check for altKey is correctly working, but attempting to
cancel the ALT event fails.

Does anyone know what is wrong with this, or have a working example that
stops ALT keypresses / Extended chars in FIREFOX ?


<script type="text/javascript">
if(document.addEventListener){
document.addEventListener("keypress", HandleEnterKey, true);
}
else{
document.attachEvent("onkeypress", HandleEnterKey);
}


// Handle the enter key for a section of a form, binding it to the provided
submit buton
function HandleEnterKey(event) {
var nav = window.Event ? true : false;
if (nav) {
return NetscapeEventHandler_KeyDown(event);
} else {
return MicrosoftEventHandler_KeyDown();
}
}

function NetscapeEventHandler_KeyDown(e) {
if (e.which == 48) {
window.status = window.status + e.which + "moz1 ";
e.returnValue = false;
e.cancel = true;
e.preventDefault();
return false;
} else if (e.altKey) {
window.status = window.status + "ALT" + e.which + "moz2 ";
e.returnValue = false;
e.cancel = true;
e.stopPropagation();
e.preventDefault();
return false;
}
return true;
}
</script>
</head>
<body>
<form action="" id="theForm">
<input type="text" id="i1" name="i1" />
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top