form onsubmit问题。
这个form没有submit为什么点击图片就能实现提交呢?<%@pagecontentType="text/html;charset=gb2312"language="j...
这个form没有submit为什么点击图片就能实现提交呢?
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<title>
聊天室
</title>
<link href="CSS/style.css" rel="stylesheet">
<script language="javascript">
function check(){
if(form1.username.value==""){
alert("请输入用户名!");form1.username.focus();return false;
}
}
</script>
<body>
<br>
<form name="form1" method="post" action="login.jsp" onSubmit="return check()">
<table width="363" height="224" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.png">
<tr>
<td height="121" colspan="3" class="word_dark"> </td>
</tr>
<tr>
<td width="53" align="center" valign="top" class="word_dark"> </td>
<td width="216" align="center" valign="top" class="word_dark">用户名:
<input type="text" name="username"></td>
<td width="94" valign="top" class="word_dark"><input type="image" name="imageField" src="images/go.jpg"></td>
</tr>
</table>
</form>
</body>
</html> 展开
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<title>
聊天室
</title>
<link href="CSS/style.css" rel="stylesheet">
<script language="javascript">
function check(){
if(form1.username.value==""){
alert("请输入用户名!");form1.username.focus();return false;
}
}
</script>
<body>
<br>
<form name="form1" method="post" action="login.jsp" onSubmit="return check()">
<table width="363" height="224" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.png">
<tr>
<td height="121" colspan="3" class="word_dark"> </td>
</tr>
<tr>
<td width="53" align="center" valign="top" class="word_dark"> </td>
<td width="216" align="center" valign="top" class="word_dark">用户名:
<input type="text" name="username"></td>
<td width="94" valign="top" class="word_dark"><input type="image" name="imageField" src="images/go.jpg"></td>
</tr>
</table>
</form>
</body>
</html> 展开
2个回答
展开全部
你都没有将表单名称传过去 怎么能判断呢
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<title>
聊天室
</title>
<link href="CSS/style.css" rel="stylesheet">
<script language="javascript">
function check(TheForm){
if(TheForm.username.value==""){
alert("请输入用户名!");
form1.username.focus();
return false;
}
}
</script>
<body>
<br>
<form name="form1" method="post" action="login.jsp" onSubmit="return check(this);">
<table width="363" height="224" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.png">
<tr>
<td height="121" colspan="3" class="word_dark"> </td>
</tr>
<tr>
<td width="53" align="center" valign="top" class="word_dark"> </td>
<td width="216" align="center" valign="top" class="word_dark">用户名:
<input type="text" name="username"></td>
<td width="94" valign="top" class="word_dark"><input type="image" name="imageField" src="images/go.jpg"></td>
</tr>
</table>
</form>
</body>
</html>
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<title>
聊天室
</title>
<link href="CSS/style.css" rel="stylesheet">
<script language="javascript">
function check(TheForm){
if(TheForm.username.value==""){
alert("请输入用户名!");
form1.username.focus();
return false;
}
}
</script>
<body>
<br>
<form name="form1" method="post" action="login.jsp" onSubmit="return check(this);">
<table width="363" height="224" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.png">
<tr>
<td height="121" colspan="3" class="word_dark"> </td>
</tr>
<tr>
<td width="53" align="center" valign="top" class="word_dark"> </td>
<td width="216" align="center" valign="top" class="word_dark">用户名:
<input type="text" name="username"></td>
<td width="94" valign="top" class="word_dark"><input type="image" name="imageField" src="images/go.jpg"></td>
</tr>
</table>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询