Chinaunix首页 | 论坛 | 博客
  • 博客访问: 341195
  • 博文数量: 329
  • 博客积分: 2633
  • 博客等级: 少校
  • 技术积分: 3633
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-22 15:43
文章分类

全部博文(329)

文章存档

2013年(244)

2012年(46)

2011年(39)

我的朋友

分类: 系统运维

2012-03-02 19:47:09

在webcontent下的image/num中放入图片 num.rar   
jsp页面中代码是:
  1. <td height="31" colspan="2" valign="top" class="STYLE15" ondragstart="return false" onselectstart="return false">
  2.                                  验证码:
  3.             <input name="yanzheng" type="text" class="input2"
  4.                          onKeyDown="if(event.keyCode==13){form1.Submit.focus();}"
  5.                                     size="8" align="bottom"
  6.                                     onMouseOver="this.style.background='#F0DAF3';"
  7.                                     onMouseOut="this.style.background='#FFFFFF'">
  8.                                     
  9.                                     <%
  10.                                     int intmethod = (int)( (((Math.random())*11))-1);
  11.                                     int intmethod2 = (int)( (((Math.random())*11))-1);
  12.                                     int intmethod3 = (int)( (((Math.random())*11))-1);
  13.                                     int intmethod4 = (int)( (((Math.random())*11))-1);
  14.                                     String intsum = intmethod+""+intmethod2+intmethod3+intmethod4;
  15.                                     //将得到的随机数进行连接

  16.                                    %>
  17.           <input type="hidden" name="verifycode2" value="<%=intsum%>">
  18.                 <span class="STYLE12"><font size="+3" color="#FF0000"><img src=Images/num/<%=intmethod %>.gif> <img src=Images/num/<%=intmethod2 %>.gif>
  19.                 
  20.                     <img src=Images/num/<%=intmethod3%>.gif> <img src=Images/num/<%=intmethod4 %>.gif></font></span>
  21.             </td>
jsp中的javascript对其先进行检查:
  1. <script language="javascript">
  2.  function mycheck(){
  3.  if (form1.UserName.value=="")
  4.  {alert("请输入用户名!");form1.UserName.focus();return;}
  5.  if(form1.PWD.value=="")
  6.  {alert("请输入密码!");form1.PWD.focus();return;}
  7.  if(form1.yanzheng.value=="")
  8.  {alert("请输入验证码!");form1.yanzheng.focus();return;}
  9.  if(form1.yanzheng.value != form1.verifycode2.value)
  10.  {alert("请输入正确的验证码!!");form1.yanzheng.focus();return;}
  11.  form1.submit();
  12.  }
  13.  </script>
阅读(885) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~