我是新來的JavaScript和我有功能召回的問題,請參見圖像附加刪除「onclick」事件的功能?
但我再次點擊應用按鈕返回像
和重複。這需要停止我有設置超時功能,但事情是它不工作。 所以這是可能的銷燬RegisterCapcha()和調用RegisterCapcha()在應用按鈕上每onclick?
這種形式顯示在應用按鈕點擊
<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的驗證碼。在提前:) <span id='close' onclick="function() { setTimeout(function() { RegisterCapcha(); }, 1000) } HideContent('job-apply'); return false;"></span>
感謝
<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>
我已經設置超時功能
您已經在onclick中創建了一個匿名函數,但您永遠不會調用它。 – jcubic
你能提一下嗎? – Rakyir