<script language=JavaScript> function isEmpty(str) { if((str==null)||(str.length==0)) return true; else return(false); } function isEmail(theStr) { var atIndex=theStr.indexOf('@'); var dotIndex=theStr.indexOf('.',atIndex); var flag=true; var theSub=theStr.substring(0,dotIndex+1); if((atIndex<1)||(atIndex!=theStr.lastIndexOf('@'))||(dotIndex<atIndex+2)||(theStr.length<=theSub.length)){flag=false;} else {flag=true;} return(flag); } function checkform(Frm) { var flag=true; if(isEmpty(Frm.name.value)) { alert("请输入您的姓名"); Frm.name.focus(); flag=false; } else if(!isEmail(Frm.mail.value)) { alert("请输入您的 E-mail"); Frm.mail.focus(); flag=false; } else {if(isEmpty(Frm.title.value)) { alert("请输入您的标题"); Frm.title.focus(); flag=false; } else if(isEmpty(Frm.content.value)) { alert("请输入您的意见"); Frm.content.focus(); flag=false; } return flag; } </script>
<!--<%@ page contentType="text/html;charset=gb2312" %>--> <html> <head> <title>意见箱</title> <meta http-equiv="Contet-Type" content="text/html;charset=gb2312"> <style type="tcxt/css"> <!--@ import "css/jsp.css";--> </style> </head> <body bgcolor="#fffff" topmargin="1"> <div align="center"> <p> </p> <table width="500" border="0" cellspacing="1"> <tr> <td> <div align="center"> <table width="500" border="0" cellspacing="2" cellpadding="1"> <tr> <td width="110"> <%@ page import="java.util.*" %> <div align="center">^o^<% java.util.Date m_date=new java.util.Date(); int nowHour=m_date.getHours(); if(nowHour<=6) {%>凌晨<%} else if(nowHour<=11) {%>上午<%} else if(nowHour<=13) {%>中午<%} else if(nowHour<=18) {%>下午<%} else {%>晚上<%}%>好</div> </td> <td width="232"> <div align="center"><font size="6" face="Fixedsys,黑体,仿宋_GB2312">意见箱 </font> </div> </td> <td width="144">今天是: <% String nowDate=m_date.toLocaleString(); nowDate=nowDate.substring(0,10); out.print(nowDate); %></td> </tr> </table> <hr> <form name="form" method="post" action="idea.jsp" onsubmit="return checkform(this)"> <div align="center"> <table width="500" cellspacing="1"> <tr> <td rowspan="2"> <div align="right">您的姓名: </div> </td> <td colspan="3" rowspan="2"> <input type="text" name="name" size="13"> </td> </tr> <tr></tr> <tr> <td width="21%" height="31"> <div align="right">您的 Email: </div> </td> <td height="31" colspan="3"> <input type="text" name="mail" size="20"> </td> </tr> <tr> <td width="21%"> <div align="right">主题: </div> </td> <td colspan="3"> <input type="text" name="title" size="30"> </td> </tr> <tr> <td width="21%"> <div align="right">您的意见: </div> </td> <td colspan="3"> <textarea name="content" cols="50" rows="6"></textarea> </td> </tr> <tr> <td colspan="4"> <div align="center"> <input type="submit" name="Submit" value="提交您的意见"> <input type="reset" name="reset" value="清除重写"> </div> </td> </tr> </table> </div> </form> </div> </td> </tr> </table> </div> </body> </html>
帮我看一下吧,我找了半天也找不出错,为什么javascript不能用呀
[此贴子已经被作者于2004-08-07 23:14:01编辑过]