<%--
网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
author yeeku.H.lee [email protected]
version 1.0
Copyright (C), 2001-2014, yeeku.H.Lee
This program is protected by copyright laws.
Program Name:
Date: 
--%><%@ page contentType="text/html;charset=GBK" errorPage="error.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title> 聊天页面 </title>
</head>
<body>
<div style="width:780px;border:1px solid black;text-align:center">
<h3>聊天页面</h3>
<p>
<textarea name="textarea" cols="90" rows="30"
readonly="readonly">${requestScope.msg}</textarea> 
</p>
<form name="form1" method="post" action="chat.do" >
<div align="center">
<input name="chatMsg" type="text" size="90"
onclick="document.form1.submit;"/>
<input type="submit" name="Submit" value="发送"/>
</div>
</form>
</div>
<script type="text/javascript">
var input = document.getElementById("chatMsg");
input.focus(); function check()
{
if (input.value == null || input.value == "")
{
alert("请输入聊天信息,不要发送空信息!");
return false;
}
} function submitChat()
{
document.getElementById("form1").onsubmit();
} document.getElementById("form1").onsubmit = check;
</script>
</body>
</html>
document.getElementById("form1").onsubmit = check;这个是什么意思?function submitChat()
{
document.getElementById("form1").onsubmit();
}这个函数又是什么意思?

解决方案 »

  1.   

    document.getElementById("form1").onsubmit = check这句话是设置form1表单的提交按钮的处理函数为check,执行完之后,点form1的提交按钮,就会进入function check中执行,
      

  2.   

    submitChat函数很简单,就是提交form1表单,
      

  3.   

    为什么我点击了表单提交按钮“发送” 发送空聊天信息,check函数没弹出窗口?
      

  4.   

    在线等。。为什么我在chatMsg什么都没输入,点击提交按钮check函数没反应?
      

  5.   

    i had killed the bug!