|
Posted by Ed Jay on 12/18/05 19:39
My form consists of text boxes, radio buttons and checkboxes. I use the
following js to trap(kill) the enter key during text box entry to prevent
inadvertent form submission:
var keys = document.all?true:false;
function keyHandler(e) {
var _ret=true;
var _char=keys?event.keyCode:e.which;
if(_char==13)
_ret=false;
return _ret;
}
I call it from within textbox form elements as
<input name="X" type="text" onkeypress="return keyHandler();">
This works fine as long as the focus is on a text box. OTOH, if I've
clicked a radio button or checkbox and then press 'Return (keycode 13)'
the form is submitted.
How do I globally protect against such inadvertency?
--
Ed Jay (remove M to respond by email)
Navigation:
[Reply to this message]
|