一: 事件:
初始化函数中:
//禁用回车 后退事件
document.onkeydown = function () {
if (window.event && (window.event.keyCode == 13 || window.event.keyCode== 8)) {
window.event.returnValue = false;
}
}
二:form 表单不可编辑:
$('#myFormId').find('input,textarea,select').attr('readonly',true);
三:禁用函数
//禁用回车后退事件
document.onkeydown = function (e) {
var elem = event.srcElement;
var name = elem.nodeName;
if (window.event && (window.event.keyCode == 13 )) {
window.event.returnValue = false;
}
if(window.event.keyCode== 8){
if( name != "INPUT" && name != "TEXTAREA"){
window.event.returnValue = false;
return;
}
if(name=='INPUT' && (elem.readOnly==true || elem.disabled ==true)){
window.event.returnValue = false ;
}
}
}