jsp中的onsubmit事件怎么不执行????
下面是我的代码点击submit按钮以后没反应呢<%@pagelanguage="java"pageEncoding="GBK"%><!DOCTYPEhtmlPUBLIC"...
下面是我的代码点击submit按钮以后没反应呢
<%@ page language="java" pageEncoding="GBK"%>
<!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=ISO-8859-1">
<title>登记注册表</title>
</head>
<body>
<form action="" method="post" name="forml" onsubmit="return userCheck()">
<table width="409" border="1">
<tr>
<td>用户名:</td> <td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码:</td> <td><input type="password" name="password"></td>
</tr>
<tr>
<td>确认:</td> <td><input type="password" name="repassword"></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="radio" name="sex" checked="checked" value="男">男
<input type="radio" name="sex" value="女">女
</td>
</tr>
<tr>
<td>出生:</td> <td><input type="text" name="born"></td>
</tr>
<tr>
<td>学历:</td>
<td><select name="schoolage" onchange="alert('您选择了'+schoolage.value)">
<option value="大专">大专</option>
<option value="本科">本科</option>
<option value="研究生">研究生</option>
<option value="博士生">博士生</option>
</select></td>
</tr>
<tr>
<td>地址:</td> <td><input type="text" name="address"></td>
</tr>
<tr>
<td>邮编:</td> <td><input type="text" name="post"></td>
</tr>
<tr>
<td>爱好:</td>
<td>
<input type="checkbox" name="like" value="游泳">游泳
<input type="checkbox" name="like" value="听歌">听歌
<input type="checkbox" name="like" value="跑步">跑步
<input type="checkbox" name="like" value="羽毛球">羽毛球
</td>
</tr>
<tr>
<td>照片:</td> <td><input type="file" name="photo"></td>
</tr>
<tr>
<td>介绍:</td>
<td><textarea name="introduce" row="5" id="introduce"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="注册">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</table>
</form>
<script language="javascript" type="text/javascrip">
function userCheck(){
if(document.forml.username.value==""){
window.alert("请输入用户名");
return false;
}
if(document.forml.password.value==""){
window.alert("请输入密码");
return false;
}
if(document.forml.repassword.value==""){
window.alert("请输入密码确认");
return false;
}
if(document.forml.repassword.value!=document.formal.password.value){
window.alert("你输入的两次密码不相同");
return false;
}
if(document.forml.born.value==""){
window.alert("请输入出生日期");
return false;
}
if(document.forml.address.value==""){
window.alert("请输入用户地址");
return false;
}
if(document.forml.introduce.value==""){
window.alert("请输入自我介绍");
return false;
}
}
</script>
</body>
</html> 展开
<%@ page language="java" pageEncoding="GBK"%>
<!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=ISO-8859-1">
<title>登记注册表</title>
</head>
<body>
<form action="" method="post" name="forml" onsubmit="return userCheck()">
<table width="409" border="1">
<tr>
<td>用户名:</td> <td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码:</td> <td><input type="password" name="password"></td>
</tr>
<tr>
<td>确认:</td> <td><input type="password" name="repassword"></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="radio" name="sex" checked="checked" value="男">男
<input type="radio" name="sex" value="女">女
</td>
</tr>
<tr>
<td>出生:</td> <td><input type="text" name="born"></td>
</tr>
<tr>
<td>学历:</td>
<td><select name="schoolage" onchange="alert('您选择了'+schoolage.value)">
<option value="大专">大专</option>
<option value="本科">本科</option>
<option value="研究生">研究生</option>
<option value="博士生">博士生</option>
</select></td>
</tr>
<tr>
<td>地址:</td> <td><input type="text" name="address"></td>
</tr>
<tr>
<td>邮编:</td> <td><input type="text" name="post"></td>
</tr>
<tr>
<td>爱好:</td>
<td>
<input type="checkbox" name="like" value="游泳">游泳
<input type="checkbox" name="like" value="听歌">听歌
<input type="checkbox" name="like" value="跑步">跑步
<input type="checkbox" name="like" value="羽毛球">羽毛球
</td>
</tr>
<tr>
<td>照片:</td> <td><input type="file" name="photo"></td>
</tr>
<tr>
<td>介绍:</td>
<td><textarea name="introduce" row="5" id="introduce"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="注册">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</table>
</form>
<script language="javascript" type="text/javascrip">
function userCheck(){
if(document.forml.username.value==""){
window.alert("请输入用户名");
return false;
}
if(document.forml.password.value==""){
window.alert("请输入密码");
return false;
}
if(document.forml.repassword.value==""){
window.alert("请输入密码确认");
return false;
}
if(document.forml.repassword.value!=document.formal.password.value){
window.alert("你输入的两次密码不相同");
return false;
}
if(document.forml.born.value==""){
window.alert("请输入出生日期");
return false;
}
if(document.forml.address.value==""){
window.alert("请输入用户地址");
return false;
}
if(document.forml.introduce.value==""){
window.alert("请输入自我介绍");
return false;
}
}
</script>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询