JavaScript总结(五)
作者:
风的低语 | 来源:发表于
2018-06-20 14:39 被阅读2次<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
window.onload=function(){
document.getElementsByTagName("form")[0].onsubmit=function(){
var user = document.getElementById("user").value;
if(user==""){
alert("null");
return false;
}
return true;
}
}
</script>
</head>
<body>
<form action="#" onsubmit="" method="get"><!--submit触发onsubmit事件-->
<p><input type="text" name="user" id="user" /></p>
<p><input type="password" name="pwd" id="pwd" /></p>
<p><input type="submit" value="登录"/></p>
</form>
</body>
</html>
本文标题:JavaScript总结(五)
本文链接:https://www.haomeiwen.com/subject/cdxjuxtx.html
网友评论