tag appears in an HTML form, a Submit object is created."/> tag appears in an HTML form, a Submit object is created.">
Home > Article > Web Front-end > What does submit mean?
The Submit object represents a submit button in an HTML form. Every time the 54b28e0e73a12e4a8ed487872a6fb5b8 tag appears in an HTML form, a Submit object is created.
Before the form is submitted, the onclick event handler is triggered, and a handler can cancel the form submission by returning false.
See Form.submit() method and Form.onsubmit event handler.
You can access a submit button by looping through the form's elements[] array, or by using document.getElementById().
IE: Internet Explorer, F: Firefox, O: Opera, W3C: W3C Standard.
Example
<html> <head> <script type="text/javascript"> function validate() { var at=document.getElementById("email").value.indexOf("@") var age=document.getElementById("age").value var fname=document.getElementById("fname").value submitOK="true" if (fname.length>10) { alert("名字必须小于 10 个字符。") submitOK="false" } if (isNaN(age)||age<1||age>100) { alert("年龄必须是 1 与 100 之间的数字。") submitOK="false" } if (at==-1) { alert("不是有效的电子邮件地址。") submitOK="false" } if (submitOK=="false") { return false } } </script> </head> <body> <form action="/example/hdom/hdom_submitpage.html" onsubmit="return validate()"> 名字(最多 10 个字符):<input type="text" id="fname" size="20"><br /> 年龄(从 1 到 100):<input type="text" id="age" size="20"><br /> 电子邮件:<input type="text" id="email" size="20"><br /> <br /> <input type="submit" value="提交"> </form> </body> </html>
The above is the detailed content of What does submit mean?. For more information, please follow other related articles on the PHP Chinese website!