Button does not specify the type as submit. Click the button to jump to the specified URL

Time:2021-3-3

Today, due to the requirements of the project, we need JS to control the submission of the form, and verify and process the data before submitting.

The HTML code is as follows

Copy code

The code is as follows:

<div>
<h3>Mobile phone number</h3>
<form needcheck=”1″ method=”post” target=”_blank” action=”http://www.go108.com.cn/go108_mobile_free_sz.php”>
<p>

</p>
< button > test immediately
</form>
</div>

After coding, there is a problem in the browser compatibility test: IE6, IE7 click the button did not reflect, jump to the specified URL, other browsers can jump normally.
I always thought that there was a problem in the JS control code, so I tracked and debugged for a long time, but I didn’t find the problem. Later, it was found that button did not specify type as submit, so I doubted whether it was the problem.
After modifying and adding the type attribute of button to submit, IE6 and IE7 function normally.

I didn’t pay attention to this problem in the past, so I went to search for data query and verification.
W3shool has a detailed description of the type attribute of button: 
https://www.jb51.net/w3school/tags/att_button_type.htm 

Copy code

The code is as follows:

The definition and usage type property specifies the type of the button. Tip: always specify the type attribute for the button. The default type of Internet Explorer is “button”, while the default value of other browsers (including W3C specification) is “submit”. It can be seen that in other browsers, the default button will submit the form after clicking, while ie will not submit the form after clicking by default. The default value of type is also a browser compatibility problem, so under mark.