---
title: JS表单验证
---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
```
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<title>Student</title>
<script language="JavaScript">
function checkForm() {
var username = document.getElementById("usernameid").value;
var password = document.getElementById("passwordid").value;
if((username=null || username=='') &&(password=null || password=='')){
alert("用户名或密码不能为空");
return false;
}else {
return true;
}
}
</script>
</head>
<body>
<form method="post" name="myform">
UserName:<input type="text" name="username" id="usernameid" ><br>
PassWord:<input type="password" name="password" id="passwordid"><br>
<input type="submit" value="登录" οnclick="return checkForm();">
<input type="reset" value="重置" >
</form>
</body>
<%
%>
<jsp:forward page="success.jsp"></jsp:forward>
</html>
```
JS登录验证null
最新推荐文章于 2021-12-05 00:24:21 发布