我想在页面提交前,验证里面的表单中的数据,但是不能完成验证,给点提示:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
成绩管理
<br> function yanzheng(){<br> var j = document.form2.id.value;<br> var k = document.form2.score.value;<br> if(j.value.length>5||k.value.length>5)<br> {alert("用户名或密码太长,请重新输入!");<br> j.value=""; k.value="";<br> j.focus();<br> return false;<br> }<br> else if(j.value==""||k.value=="")<br> {alert("用户名或密码部能为空!");<br> j.value=""; k.value="";<br> j.focus();<br> return false;<br> }<br>
学号: |
|
科目: |
java jsp spring hibernate struts2 |
成绩: |
|
|
<form name="form2" action="add.action" method="post" onSubmit="return yanzheng()">
<table>
<tr>
<td>
学号:
</td>
<td>
<input id="id" type="text" name="score.UserId">
</td>
</tr>
<tr>
<td>
成绩:
</td>
<td>
<input id="score" type="text" name="score.Score">
</td>
</tr>
<tr>
<td>
科目号:
</td>
<td>
<select name="course.Id">
<option value="1">
java
</option>
<option value="2">
jsp
</option>
<option value="3">
spring
</option>
<option value="4">
hibernate
</option>
<option value="5">
struts2
</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="新增">
</td>
</tr>
</table>
</form>
</body>