JSP中方法函数不调用
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>MyHtml.ht...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" language="javascript">
function validate (a)
alert (form1.userid.value)
{
if(form1.userid.value.length=="")
{ alert ("");
return false;
}
}
</script>
</head>
<body bgcolor="#66CCFF" >
<h1 align="center">认证系统</h1>
<form action="index.jsp" method="post" name="form1" onSubmit="return validate (a)" >
<table border="0" align="center" bgcolor="#ffffff" >
<tr>
<td width="100" height="25" align="right" >用户名:</td>
<td width="190" >
<input type="text" name="userid" value=""> </td>
</tr>
<tr>
<td height="25" align="right"> 密码:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td height="20" colspan="4" align="center">
<input type="submit" value="提交">
<input type="reset" name="reset" value="重置">
</td>
</table>
</form>
</body>
</html>
大神们帮我看看是那里出错了。我是个初学者~~~~
onSubmit="alert(from1.userid.value)"
这句加进去就可以执行。换成我编写的函数validate(a)就不执行了。这里面我加了一个 alert 想验证一下也不执行。 展开
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" language="javascript">
function validate (a)
alert (form1.userid.value)
{
if(form1.userid.value.length=="")
{ alert ("");
return false;
}
}
</script>
</head>
<body bgcolor="#66CCFF" >
<h1 align="center">认证系统</h1>
<form action="index.jsp" method="post" name="form1" onSubmit="return validate (a)" >
<table border="0" align="center" bgcolor="#ffffff" >
<tr>
<td width="100" height="25" align="right" >用户名:</td>
<td width="190" >
<input type="text" name="userid" value=""> </td>
</tr>
<tr>
<td height="25" align="right"> 密码:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td height="20" colspan="4" align="center">
<input type="submit" value="提交">
<input type="reset" name="reset" value="重置">
</td>
</table>
</form>
</body>
</html>
大神们帮我看看是那里出错了。我是个初学者~~~~
onSubmit="alert(from1.userid.value)"
这句加进去就可以执行。换成我编写的函数validate(a)就不执行了。这里面我加了一个 alert 想验证一下也不执行。 展开
2个回答
展开全部
你代码格式写的太糟糕了,格式一点不对就不会执行的
<script type="text/javascript" language="javascript">
function validate (a){
alert (form1.userid.value) ;
if(form1.userid.value.length=="") {
alert ("");
return false;
}else{
return true;
}
}
</script>
<script type="text/javascript" language="javascript">
function validate (a){
alert (form1.userid.value) ;
if(form1.userid.value.length=="") {
alert ("");
return false;
}else{
return true;
}
}
</script>
追问
这些(){}的摆放位置不正确!
你的答案是对的~~~~编写的程序不够严谨是个问题!
以后改正!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询