You are here: Global (page) kill enter key « HTML « IT news, forums, messages
Global (page) kill enter key

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация