删除“onclick”事件的功能?

时间:2016-05-23 10:52:30

标签: javascript jquery html

我是javascript的新手,我的功能调用有问题,请参阅图片附件

Image1

但我再次单击“应用”按钮,它会返回

image 2

并重复。这需要停止我已设置超时功能,但事情是它无法正常工作。 这样可以在应用按钮的每个onclick上销毁RegisterCapcha()并调用RegisterCapcha()

点击应用按钮时显示的此表单

<form method="POST" id="careersForm" action="../php/emailsend.php enctype="multipart/form-data" > 
       <tr>
        <td>First Name  </td>
        <td><input type="TextBox" name="First_Name" class="applytext" requiredfield= "true" id="First_Name"></td>
       </tr>
       <tr>
        <td>Last Name </td>
        <td><input type="TextBox" name="Last_Name" class="applytext" required id="Last_Name"></td>
       </tr>
       <tr>
        <td>E-mail  </td>
        <td><input type="email" id="emailid" name="email" class="applytext"  required onblur="validateEmail(this)" />
         <label id="valemailid" style="color:red;"></label>
        </td>
       </tr>
       <tr>
        <td>Phone</td>
        <td><input type="text" id="Phone_No" name="Phone_No_No" class="applytext" placeholder="111-111-1111"; pattern="^[0-9]{3}[0-9]{3}[0-9]{4}$" required onfocus="this.placeholder=''" onblur="if(this.placeholder == '') { this.placeholder='(1-111-111-1111)'}" onkeypress="return isNumber(event)"/><span id="Phone_NoError" style="color:lightgray"><span></td>
       </tr>
       <tr>
        <td>Attachment  </td>
        <td><input type="file" id="fileUpload" name="attachment" maxlength="50" class="applytext" style="color: rgb(51, 51, 51);"><br />
         <span id="lblError" style="color: red;"></span>
        </td>
       </tr>
       <tr>
                <td colspan="2" class="applytable" >
                    <div class="editor-field">
                        <p>
                            <label>
                                Enter the text shown below:
                                <input type="text" id="captchaText" onkeyup="javascript:EnableApply();" /></label></p>
                        <p id="captcha">
                        </p>
                    </div>
                </td>
            </tr>
       <tr>
        <td colspan="2">
         <input type="submit" id="submit" name="button" disabled="disabled" class="send-resume" value="SEND" onclick="return ValidateExtension()" style="margin-left:24%;">
         <input type="reset" value="RESET" onclick="clearForm()" style="margin-left:8%">
        </td>
       </tr>
      </form> 

JS for captcha。

<script type="text/javascript">

    function EnableApply() {
        var OriginalCaptcha = $('#careersForm').data('captchaText');
        var userCapcha = $('#captchaText').val();

        if (OriginalCaptcha == userCapcha) {

            $('#submit').removeAttr('disabled');
        }
        else {
            $('#submit').attr('disabled', 'disabled');

        }
    }

    function RegisterCapcha() {
        $("#careersForm").clientSideCaptcha({
            input: "#captchaText",
            display: "#captcha",
            pass: function () { alert("Passed!"); return false; },
            fail: function () { alert("Failed!"); return false; }
        });
    }
</script>

我在<span id='close' onclick="function () { setTimeout(function () { RegisterCapcha(); }, 1000) } HideContent('job-apply'); return false;"></span>

中设置了超时功能

提前感谢:)

1 个答案:

答案 0 :(得分:0)

您不应该使用客户端验证码...但是要回答您的问题

您可以尝试以下

function RegisterCapcha() {
        $("#captcha").html(''); //reset the generated captcha first
        $("#captchaText").val('');
        $("#careersForm").clientSideCaptcha({
            input: "#captchaText",
            display: "#captcha",
            pass: function () { alert("Passed!"); return false; },
            fail: function () { alert("Failed!"); return false; }
        });
    }