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?

What does submit mean?

藏色散人
藏色散人Original
2019-05-20 09:12:0125737browse

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.

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>

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

Statement:
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
Previous article:what is css codeNext article:what is css code