In web development, if there is only one INPUT element in the form of the page, press ENTER in the input box of the INPUT element (note: There is no event processing to write the corresponding onkeydown, etc.), then the browser will submit the form by default, see the following code:
<HTML> <Head> <title>Default Submission Form when there is only one INPUT element on the page</title> </Head> <Body> <formAction= "Http://www.baidu.com"name= "MyForm"Method= "Get"> <inputname= "Contenta"type= "text"value= "Enter Submit" /></BR> </form> </Body> </HTML>
So how to prohibit, there are two methods of prohibition:
[1] Only one occurrence, you can add a hidden INPUT element in the form, the modified code is as follows:
<HTML> <Head> <title>Default Submission Form when there is only one INPUT element on the page</title> </Head> <Body> <formAction= "Http://www.baidu.com"name= "MyForm"Method= "Get"> <inputname= "Contenta"type= "text"value= "Enter Submit" /></BR> <inputtype= "text"style= "Display:none"> </form> </Body> </HTML>
[2] Disabling the onsubmit event for form:
<HTML> <Head> <title>Default Submission Form when there is only one INPUT element on the page</title> </Head> <Body> <formonsubmit= "return false;"Action= "XXX"name= "MyForm"Method= "Get"> <inputname= "Contenta"type= "text"value= "Enter to Submit" /></BR> </form> </Body> </HTML> <Scripttype= "Text/javascript">functionUpdate () {document.forms[0].action="${contextpath}updateaction.action"; document.forms[0].submit ();}</Script>
HTML Web page Form form has only one input text element, press ENTER default commit