[imp] Pressing Enter key in To/Cc/Bcc results in sending a mail.

Harakiri harakiri_23 at yahoo.com
Fri Oct 12 15:33:39 UTC 2007


--- Andrew Morgan <morgan at orst.edu> wrote:
> 
> Personally, I don't know if there is a way to
> prevent the web browser from 
> capturing the Enter key and using it to submit the
> form.  I know that is 
> the default behavior with web forms.

Thats very easy with javascript, just overwrite the
onkeypress event of the formular fields To, Cc, and
Bcc, like

window.onload = function ()
		{
			init();	
		}
 function init() {

            document.forms[0].someField.onkeypress =
submitEnter;
        }

 function submitEnter(theKey)
        {
            var agt =
navigator.userAgent.toLowerCase();
            var is_ie = ((agt.indexOf("msie") != -1)
&& (agt.indexOf("opera") == -1));

            if (!is_ie) {
                if (theKey.which == "13") return
false;           } else {
                if (window.event.keyCode == "13")
return false;            }
        }


       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  


More information about the imp mailing list