js 屏蔽backspace键
if (typeof window.event != 'undefined') {
document.onkeydown = function() {
var type = event.srcElement.type;
var code = event.keyCode;
return ((code != 8 && code != 13) ||
(type == 'text' && code != 13 ) ||
(type == 'textarea') ||
(type == 'submit' && code == 13))
}
} else { // FireFox/Others
document.onkeypress = function(e) {
var type = e.target.localName.toLowerCase();
var code = e.keyCode;
if ((code != 8 && code != 13) ||
(type == 'input' && code != 13 ) ||
(type == 'textarea') ||
(type == 'submit' && code == 13)) {
return true;
} else {
return false ;
}
}
}