Qusiera aportar con otra posible solución. Es una función que hice para cancelar la tecla enter en los formularios.
Código PHP:
//Si es internet explorer debe tener el objeto ActiveXObject
navigator.IE = !( !window.ActiveXObject );
function cancelKeySubmit( idform )
{
//arreglo con los campos del formulario
var formtarget = document.getElementById( idform ).elements;
//funcion que cancela los eventos
var action = function( e ){
e = e || window.event;
e.eventKey = navigator.IE ? e.keyCode : e.which;
return ( e.eventKey != 13 );
};
//recorremos los campos y verificamos que el campo no sea un textarea
for( var i = 0 ; i < formtarget.length ; i++ )
if( formtarget[i].type != "textarea" )
formtarget[i].onkeypress = action;
//devolvemos true para no obligar al motor a que devuelva algo
return true;
}
window.onload = function(){
cancelKeySubmit( "alo" );//"alo" es el ID del formulario
};
Saludos