form表单input标签回车键禁用表单提交,走js方法提交

给form标签加 οnkeydοwn=“if(event.keyCode==13)return false;”
进止input回车,提交表单

给input标签添加 οnkeydοwn=“BindEnter(event)”
或者给body添加 οnkeydοwn=“BindEnter(event)”
就会执行 BindEnter()方法了

<body  onkeydown="BindEnter(event)" >
	<form  class="form-x" onkeydown="if(event.keyCode==13)return false;" >
	       
	     <input  onkeydown="BindEnter(event)"  type="text" id="card_no" name="card_no"  class="infos" />
	
	     <input type="button" onclick="subform()" value="提交" />
	      
	form>
	
	<script>
	function BindEnter(obj) {
	        if(obj.keyCode == 13)
	        {
	            var str=$('.form-x').serialize()
		        window.location.href="{:url('qcwap/gamecontinue/memlists')}?"+str
	        }
	    }
	script>
body>

你可能感兴趣的:(javascript,前端,html)