日期:2014-05-17  浏览次数:20790 次

我的onsubmit为什么不起作用?
我的onsubmit为什么不起作用?我找了很久,没有找到原因,请各位给看看

JScript code
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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">
<link rel="stylesheet" type="text/css" href="style/main.css">
<title>会员注册</title>
<style type="text/css">
<!--

h3 {
    font-size:14px;
    font-weight:bold;
}

pre,p {
    color:#1E7ACE;
    margin:4px;
}
input, select,textarea {
    padding:1px;
    margin:2px;
    font-size:12px;
}
.buttom{
    padding:1px 10px;
    font-size:12px;
    border:1px #1E7ACE solid;
    background:#D0F0FF;
}
#formwrapper {
    width:95%;
    margin:15px auto;
    padding:20px;
    text-align:left;
}

fieldset {
    padding:10px;
    margin-top:5px;
    border:0px solid #1E7ACE;
    background:#fff;
}

fieldset legend {
    color:#1E7ACE;
    font-weight:bold;
    background:#fff;
}

fieldset label {
    float:left;
    width:120px;
    text-align:right;
    padding:4px;
    margin:1px;
}

fieldset div {
    clear:left;
    margin-bottom:2px;
}

.enter{ text-align:center;}
.clear {
    clear:both;
}

-->
</style>
<script type="text/javascript">
    function jiaoyan(form){
        
        if(form.name.value.trim() == ""){
            alert("您必须输入姓名");
            return false;
        }
        if(form.nickname.value.trim() == ""){
            alert("您必须输入昵称");
            return false;
        }
        if(form.password.value.trim() == ""){
            alert("您必须输入密码");
            return false;
        }
        return true;
    }
</script>
</head>
<body>

    <!-- 首页的导航条 -->
    <jsp:include page="/NavServlet?method=navList"></jsp:include>
    <!-- 首页中间 -->
    <div id="mid">
    <!-- 首页左边 -->
        <div id="left" style="text-align:left">
            <font color="red">${error }</font>
            <hr>
<!-- 主界面 -->
<div class="h2title">会员注册</div>
    <div id="formwrapper">
        <form action="MemberServlet" method="post" onsubmit="return jiaoyan(this)">
        <input type="hidden" name="method" value="reg">
        <fieldset>    
            <div>
                <label for="name">姓名</label>
                <input type="text" name="name" id="name"  size="30" maxlength="200" /> 
                <br />    
            </div>
            <div>
                <label for="email">email</label>
                <input type="text" name="email" id="email" size="30" maxlength="100" /> 
                <br />    
            </div>
            <div>
                <label for="nickname">昵称</label>
                <input type="text" name="nickname" id="nickname" size="30" maxlength="100" /> 
            </div>
            <div>
                <label for="password">密码</label>
                <input type="password" name="password" id="password"  size="30" maxlength="100" /> 
            </div>
            <div&