What does submit mean?

藏色散人
Release: 2019-05-22 09:46:14
Original
25741 people have browsed it

The Submit object represents a submit button in an HTML form. Every time the tag appears in an HTML form, a Submit object is created.

What does submit mean?

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>
Copy after login

The above is the detailed content of What does submit mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template