JS点击事件:简单的客户端校验
<html>
<head>
<title>点击事件</title>
<meta http-equiv="content-type"
content="text/html; charset=UTF-8">
<script type="text/javascript">
function toSubmit(){
var username=document.getElementById
("username").value;
if(username==""){//客户端JS验证
alert("请输入用户名");
return;
}
document.getElementById("info").submit();
}
</script>
</head>
<body>
<form action="http://www.baidu.com" id="info" >
用户名:<input type="text" value="" id ="username"/>
<input type="button" value="提交"
onclick="toSubmit()"/>
</form>
</body>
</html>
很多事情即将开始,很多人的命运即将改变