javascript 验证输入数据是否为空,没运行
<%@pagelanguage="java"import="java.util.*"pageEncoding="gb2312"%><!DOCTYPEHTMLPUBLIC"...
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>addnewcourt</title>
<style type="text/css">
body{
text-align:center
}
#newcourttile{
margin-left: auto;
margin-right: auto;
font-size:25px;
position: absolute; left: 600px; top: 90px
}
#newcourttable{
text-align:center
margin-left: auto;
margin-right: auto;
position: absolute; left: 500px; top: 140px
}
</style>
<script type="text/javascript">
function check(){
alter("ok");
if(document.newcourtform.CourtName.value==''){
alter("场地名不能为空");
document.newcourtform.CourtName.focus();
return false;
}
else if(document.newcourtform.CourtKind.value==''){
alter("场地种类不能为空");
return false;
}
else if(document.newcourtform.CourtPrice.value==''){
alter("场地价格不能为空");
return false;
}
else return false;
}
</script>
</head>
<body>
<div id="newcourttile">
新建场地
</div>
<div id="newcourttable">
<form action="addnewcourt" method="post" name="newcourtform" onSubmit="return check()">
<table>
<tr>
<td>场地名</td>
<td><input type="text" name="CourtName"/></td>
</tr>
<tr>
<td>场地类型</td>
<td><input type="text" name="CourtKind"/></td>
</tr>
<tr>
<td>场地价格</td>
<td><input type="text" name="CourtPrice"/></td>
</tr>
<tr>
<td><input type="submit" value="保存" /></td>
<td><input type="button" value="取消" /></td>
</tr>
</table>
</form>
</div>
</body>
</html> 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>addnewcourt</title>
<style type="text/css">
body{
text-align:center
}
#newcourttile{
margin-left: auto;
margin-right: auto;
font-size:25px;
position: absolute; left: 600px; top: 90px
}
#newcourttable{
text-align:center
margin-left: auto;
margin-right: auto;
position: absolute; left: 500px; top: 140px
}
</style>
<script type="text/javascript">
function check(){
alter("ok");
if(document.newcourtform.CourtName.value==''){
alter("场地名不能为空");
document.newcourtform.CourtName.focus();
return false;
}
else if(document.newcourtform.CourtKind.value==''){
alter("场地种类不能为空");
return false;
}
else if(document.newcourtform.CourtPrice.value==''){
alter("场地价格不能为空");
return false;
}
else return false;
}
</script>
</head>
<body>
<div id="newcourttile">
新建场地
</div>
<div id="newcourttable">
<form action="addnewcourt" method="post" name="newcourtform" onSubmit="return check()">
<table>
<tr>
<td>场地名</td>
<td><input type="text" name="CourtName"/></td>
</tr>
<tr>
<td>场地类型</td>
<td><input type="text" name="CourtKind"/></td>
</tr>
<tr>
<td>场地价格</td>
<td><input type="text" name="CourtPrice"/></td>
</tr>
<tr>
<td><input type="submit" value="保存" /></td>
<td><input type="button" value="取消" /></td>
</tr>
</table>
</form>
</div>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询