Firefox: Filter Extended Ascii from Form

  • Follow


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>


0
Reply news 9/17/2005 4:34:17 AM


0 Replies
327 Views

(page loaded in 0.023 seconds)

Similiar Articles:













7/24/2012 4:21:02 AM


Reply: