急 用JavaScript在页面上进行判断验证码

来源:百度知道 编辑:UC知道 时间:2024/07/03 03:47:50
我在jsp页面上进行验证码的判断,代码如下:if (HOPE_form.validate.value.length==0){
alert("出错了,您没有填写验证码。");
HOPE_form.validate.focus();
return false;
}

if (HOPE_form.validate.value=<%=request.getSession().getAttribute("rand")%>){
alert("出错了,您输入的验证码不正确。");
HOPE_form.validate.focus();
return false;
}
<input type="image" name="imageField" src="images/User_Login_0_13.gif" style=" width:40px; height:40px;"
onSubmit="function HOPE_return();" />
<td align="left"><img name="validate" src="ValidateCode" alt="验证码"></td>

请高手帮帮忙!
if (HOPE_form.code.value.length==0){
alert("出错了,您没有填写验证码。");
HOPE_form.validate.focus();
return false;
}
var temp = '<%=request.getSess

if (HOPE_form.validate.value!='<%=request.getSession().getAttribute("rand")%>'){
alert("出错了,您输入的验证码不正确。");
HOPE_form.validate.focus();
return false;
}

if (HOPE_form.validate.value=<%=request.getSession().getAttribute("rand")%>)
应该改变:
if (HOPE_form.validate.value!=<%=request.getSession().getAttribute("rand")%>){

不过最好还是写在cookies里面

if (HOPE_form.validate.value=<%=request.getSession().getAttribute("rand")%>) 改为

if (HOPE_form.validate.value != <%=request.getSession().getAttribute("rand")%>)