<input type= "button" > <input type= "Submit" >
The difference between the two is
The button does not automatically submit the form data, only performs the event handling within the onclick, and if the data is to be submitted, it needs to be added document.form1.submit (); such as
Submit the form data automatically, use it to add verification, put back to verify return ture; or return false;
<input type= "Submit" name= "submit" value= "register" onclick= "return check (); ">
<script>
Funciotn Check ()
{
Verify that the conditional return ture is met;
The condition return false is not satisfied;
}
</script>
[<asp:button onclick= "" Onclientclick= "return Check ()" >
Server-side controls can be added with OnClientClick validation. ]
It is important to note that the <button> </button> control has a special case where the default type of Internet Explorer is "button" and the default value in other browsers is "Submit" when you use the button to add Specifies the Type value.
But the use of asynchronous operations, such as $.ajax (), success will jump after the page, when type= "submit", no validation, after the execution of $.ajax (), and will not jump, will automatically submit the form, the effect is to refresh a bit, and will not jump to its His page.
For example:
$ ("#save"). Click (function () { var supplyvalues = jquery.map ($landlordsupply. Filter ( ": Checked"), function (a) { return $ (a). Val (); }) $.getjson ("/webserver/addhouseinfo.ashx", { " Type ": " addhousefacility ", " facility ": supplyvalues.join () }, function (R) { if (r.err == "0") { &Nbsp; alert ("published successfully"); window.location = "submithouse.aspx?ti=" + math.random (); } else { alert (R.err); }; }); return false;
This sentence must be added before the form can be submitted, and this sentence cannot be added to
Getjson () inside, Async added to the inside no effect, only after the asynchronous execution//plus this sentence, make a judgment, will not continue to execute the Submit. })
The difference between submit and button in HTML/window.location.href does not jump