当前位置: 代码迷 >> JavaScript >> form表单中去掉默许的enter键提交并绑定js方法
  详细解决方案

form表单中去掉默许的enter键提交并绑定js方法

热度:242   发布时间:2013-02-28 11:33:09.0
form表单中去掉默认的enter键提交并绑定js方法
<form id="index-search_form" method="post" >  
        				<input type="text" id="s" value="" 
        				onkeydown="javascript:if(event.keyCode==13) return false;" 
        				onkeyup="javascript:if(event.keyCode==13) dosearch();"   
        				class="swap_value" />   
        				<img onclick="dosearch();"  
        				src="${ctx }/MINIUI/scripts/miniui/themes/default/images/img/btn_search_box2.gif" 
        				width="36" height="26" id="go" alt="Search" title="Search" />
      				</form>  


function dosearch(){   
	    var keywords=$("#s").val();   
	    keywords=encodeURI(keywords);      
	    keywords=encodeURI(keywords);    
	   // window.open("${ctx}/DispatchAction.do?serviceName=SearchWeb&efFormEname=FS01&methodName=query&i-0-page=0&i-0-keywords="+keywords+"&i-0-moduleId=bmoa_badc");     
	    location.href="${ctx}/DispatchAction.do?serviceName=SearchWeb&efFormEname=FS01&methodName=query&i-0-page=0&i-0-keywords="+keywords;     
	} 


  相关解决方案