Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在我的HTML弹出窗口中使用验证码_Javascript_Html_Asp Classic_Captcha - Fatal编程技术网

Javascript 如何在我的HTML弹出窗口中使用验证码

Javascript 如何在我的HTML弹出窗口中使用验证码,javascript,html,asp-classic,captcha,Javascript,Html,Asp Classic,Captcha,我想在我的HTML弹出窗口中使用验证码,我在网上发现了一个简单的验证码,但是我如何编写if语句以确保此人在解决验证码之前不能按下同意按钮?如何引用captcha asp文件 我在HTML中使用的部分代码: 注意:我检查了if,但是如何引用html文件之外的asp文件中的布尔值 ן»¿<%@LANGUAGE="VBSCRIPT"%> <% Response.CacheControl = "no-cache" Response.AddHeader "pragma","no-cach

我想在我的HTML弹出窗口中使用验证码,我在网上发现了一个简单的验证码,但是我如何编写if语句以确保此人在解决验证码之前不能按下同意按钮?如何引用captcha asp文件

我在HTML中使用的部分代码:

注意:我检查了if,但是如何引用html文件之外的asp文件中的布尔值

ן»¿<%@LANGUAGE="VBSCRIPT"%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "pragma","no-cache"
Response.Expires = -1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" language="javascript">
        function RefreshImage(valImageId) {
            var objImage = document.getElementById(valImageId)
            if (objImage == undefined) {
                return;
            }
            var now = new Date();
            objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
        }
    </script>
</head>
<body>
    <form name="form1" id="form1" method="post">
    <div style="text-align: center; margin-top: 20px;">
        <%
        if Request.ServerVariables("REQUEST_METHOD") = "POST" and IsEmpty(Request.Form("btnRetry")) then
            Dim lblResult, lblColor
            if IsEmpty(Session("ASPCAPTCHA")) or Trim(Session("ASPCAPTCHA")) = "" then
                lblResult = "This test has expired."
                lblColor = "red"
            else
                Dim TestValue : TestValue = Trim(Request.Form("txtCaptcha"))
                '//Uppercase fix for turkish charset//
                TestValue = Replace(TestValue, "i", "I", 1, -1, 1)
                TestValue = Replace(TestValue, "ִ°", "I", 1, -1, 1)
                TestValue = Replace(TestValue, "ִ±", "I", 1, -1, 1)
                '////////////////////
                TestValue = UCase(TestValue)

                if StrComp(TestValue, Trim(Session("ASPCAPTCHA")), 1) = 0 then
                    lblResult = "CAPTCHA PASSED"
                    lblColor = "green"

                else
                    lblResult = "CAPTCHA FAILED"
                    lblColor = "red"
                end if
                '//IMPORTANT: You must remove session value for security after the CAPTCHA test//
                Session("ASPCAPTCHA") = vbNullString
                Session.Contents.Remove("ASPCAPTCHA")
                '////////////////////
            end if
        %>
        <p><span style="color: <%=lblColor%>; font-weight: bold;"><%=lblResult%></span></p>
        <input type="submit" name="btnRetry" id="btnRetry" value="Take another test" />
        <%else%>
        <img src="captcha.asp" id="imgCaptcha" />&nbsp;<a href="javascript:void(0);" onclick="RefreshImage('imgCaptcha');">Get a new challenge</a><br />
        Write the characters in the image above<br />
        <input type="text" name="txtCaptcha" id="txtCaptcha" value="" /><br />
        <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
        <%end if%>
    </div>
    </form>
</body>
</html>

一个可能的解决办法是使用这个

它提供了一个三步解决方案

1-将文件复制到您的解决方案中

2-添加客户端代码

3-添加服务器端代码


我一直在使用reCaptcha项目中提供的API——它们有很好的示例代码,这样我就不用一直重新发明轮子了!

验证码验证逻辑必须在服务器端而不是客户端实现。如果您能详细解释一下,我会介意的。在本例中,我是从草稿中编写站点的。您的意思是什么?您的服务器端是asp classic还是java?如何引用captcha asp文件?嗯,你觉得@Freelex怎么样?刚才注意到java标签已经尝试过了,但是我该如何编写capthca的条件呢?网站上有大量的文档,你在这里询问java,但是其他语言指南也有详细说明。
<!-- #include file ="BotDetect.asp" -->
</head>

[…]

<% ' Adding BotDetect Captcha to the page 
    Dim SampleCaptcha : Set SampleCaptcha = (New Captcha)("SampleCaptcha")
    SampleCaptcha.UserInputID = "CaptchaCode"
    Response.Write SampleCaptcha.Html
%>

<input name="CaptchaCode" id="CaptchaCode" type="text" />
<% If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim isHuman : isHuman = SampleCaptcha.Validate()

    If Not isHuman Then 
        'show error message
    Else 
        'Captcha validation passed
    End If 
End If %>