<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<body>
<script str="Scripts/JScript.js"type="text/javascript">
function addcheck(){
var username1=document.getElementById("username").value;
var password1=document.getElementById("password").value;
var newword1=document.getElementById("newword").value;
if(username1 == " "){
alert("用户名不能为空!");
//document.getElementById("username").focus();
return false;
}
if(password1 == " "){
alert("密码不能为空!");
//document.getElementById("password").focus();
return false;
}
if(password1 != newword1){
alert("两次输入密码不相同!");
//document.getElementById("newword").focus();
return false;
}
return true;
}
</script>
<center>
<font face="楷体" size="6" color="#000">注册界面</font>
<form action = "checkRegister.jsp" method = "post" onsubmit = "return addcheck()">
<table width="300" height = "180" border="5" bordercolor="#A0A0A0">
<tr>
<th>用户名:</th>
<td><input type="text" name="username" value="输入16个字符以内" maxlength = "16" onfocus = "if(this.value == '输入16个字符以内') this.value =''"></td>
</tr>
<tr>
<th>输入密码:</th>
<td><input type="text" name="password" value="输入20个字符以内" maxlength = "20" onfocus = "if(this.value == '输入20个字符以内') this.value =''"></td>
</tr>
<tr>
<th>确认密码:</th>
<td><input type="text" name="newword" value="重新输入密码" maxlength = "20" onfocus = "if(this.value == '重新输入密码') this.value =''"></td>
</tr>
<tr>
<td colspan = "2" align = "center">
<input type="submit" value="注 册" id="submit"/>
<input type="reset" value="重 置">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
这个程序运行时输入用户名为空,密码为空,和两次密码不一样的时候也都能提交信息并成功注册,信息检查的功能没有实现。有哪位大佬知道是什么地方出现问题了吗?能帮忙解决一下吗?非常感谢!!!