本文介绍了表单在ENTER按钮上提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面给出的表格。现在,当我在#search_string中输入内容并按按钮时,会自动将其转到 action = Paid
...我不是确定为什么表单在按钮上提交。 <! - < div id =startsearchbox> - >
< form id =bigsearchform_newmethod =postaction =Paid>
<! - < label style =display:nonefor =search_string> SEARCH< / label> - >
< input id =search_stringname =search_stringtype =textclass =startnewsearch roundedplaceholder =Search ...maxlength =500>
< input id =searchButton1type =buttonclass =searchButtontitle =点击此处搜索数据库>
< input type =hiddenname =antiCSRFvalue ={{acsrf}}/>
< input type =hiddenname =session_idvalue ={{session_id}}/>
< input type =hiddenname =goods_idid =goods_id/>
< / form>
解决方案
浏览器提交表单的默认行为按钮。如果要防止表单提交使用 onSubmit
事件处理程序。
I have form as given below. Now, when I enter something in the #search_string and press button it automatically takes it to the action=Paid
... I'm not sure why the form gets submitted on the button..
<!--<div id="startsearchbox">-->
<form id="bigsearchform_new" method="post" action="Paid">
<!--<label style="display:none" for="search_string">SEARCH</label>-->
<input id="search_string" name="search_string" type="text" class="startnewsearch rounded" placeholder="Search..." maxlength="500" >
<input id="searchButton1" type="button" class="searchButton" title="Click here to search the database">
<input type="hidden" name="antiCSRF" value="{{acsrf}}" />
<input type="hidden" name="session_id" value="{{session_id}}" />
<input type="hidden" name="commodity_id" id="commodity_id" />
</form>
解决方案
It's default behavior of the browser to submit the form on button. If you want to prevent form submitssion use onSubmit
event handler.
这篇关于表单在ENTER按钮上提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!