登录界面监听回车事件,判断必填的两个字段是否为空,最后提交

	<script >
		document.onkeydown = function(event_e){
			if( window.event )
			event_e = window.event;
			var int_keycode = event_e.charCode||event_e.keyCode;
			if(int_keycode == 13){ 
				if(document.getElementById("userid").value.length==0){
					document.getElementById("userid").focus();
					 return false;
				}else if(document.getElementById("userpwd").value.length==0){
					document.getElementById("userpwd").focus();
					 return false;
				}
			}
		}
	</script>

 

你可能感兴趣的:(回车事件,javasctipt)