HTML事件属性onsubmit
2018-01-05 13:58 更新
HTML事件属性onsubmit
提交表单时会触发 onsubmit
属性事件。
HTML5中的新功能
没有。
句法
<form onsubmit="script">
支持的标签
<form>, <keygen>
浏览器兼容性
![]() |
![]() |
![]() |
![]() |
![]() |
|
---|---|---|---|---|---|
onsubmit |
Yes | Yes | Yes | Yes | Yes |
例子
<!DOCTYPE html>
<html>
<body>
<form action="a.php" onsubmit="myFunction()">
Enter name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
<script>
function myFunction() {
console.log("The form was submitted");
}
</script>
</body>
</html>
以上内容是否对您有帮助:
更多建议: