在webcontent下的image/num中放入图片
num.rar
jsp页面中代码是:
- <td height="31" colspan="2" valign="top" class="STYLE15" ondragstart="return false" onselectstart="return false">
- 验证码:
- <input name="yanzheng" type="text" class="input2"
- onKeyDown="if(event.keyCode==13){form1.Submit.focus();}"
- size="8" align="bottom"
- onMouseOver="this.style.background='#F0DAF3';"
- onMouseOut="this.style.background='#FFFFFF'">
-
- <%
- int intmethod = (int)( (((Math.random())*11))-1);
- int intmethod2 = (int)( (((Math.random())*11))-1);
- int intmethod3 = (int)( (((Math.random())*11))-1);
- int intmethod4 = (int)( (((Math.random())*11))-1);
- String intsum = intmethod+""+intmethod2+intmethod3+intmethod4;
- //将得到的随机数进行连接
- %>
- <input type="hidden" name="verifycode2" value="<%=intsum%>">
- <span class="STYLE12"><font size="+3" color="#FF0000"><img src=Images/num/<%=intmethod %>.gif> <img src=Images/num/<%=intmethod2 %>.gif>
-
- <img src=Images/num/<%=intmethod3%>.gif> <img src=Images/num/<%=intmethod4 %>.gif></font></span>
- </td>
jsp中的javascript对其先进行检查:
- <script language="javascript">
- function mycheck(){
- if (form1.UserName.value=="")
- {alert("请输入用户名!");form1.UserName.focus();return;}
- if(form1.PWD.value=="")
- {alert("请输入密码!");form1.PWD.focus();return;}
- if(form1.yanzheng.value=="")
- {alert("请输入验证码!");form1.yanzheng.focus();return;}
- if(form1.yanzheng.value != form1.verifycode2.value)
- {alert("请输入正确的验证码!!");form1.yanzheng.focus();return;}
- form1.submit();
- }
- </script>
阅读(885) | 评论(0) | 转发(0) |