Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

java - Form gets submitted on ENTER button

I have form as given below. Now, when I enter something in the #search_string and press ENTER button it automatically takes it to the action=Paid... I'm not sure why the form gets submitted on the ENTER 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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's default behavior of the browser to submit the form on ENTER button. If you want to prevent form submitssion use onSubmit event handler.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...