0
我想第一次使用reCaptcha,這是迄今爲止我寫的代碼,但它似乎並沒有工作。reCaptcha第一次計時器問題
這是我的HTML表單:
<form method="post" action=''>
<cfoutput>
<input type="hidden" name="isPost" value="1" />
First Name: <input type="text" name="firstname" placeholder="First name" required><br />
Last Name: <input type="text" name="lastname" placeholder="Last name" required><br />
Email: <input type="email" name="email" placeholder="[email protected]" required><br />
Zip Code: <input id="zip" type="text" pattern="[0-9]{5}" name="zipcodex" placeholder="ex." required /><br />
Home Phone: <input type="tel" pattern='[0-9]{10}' name="homephone" placeholder="ex. 3335551234" required><br />
Cell Phone: <input type="tel" pattern='[0-9]{10}' name="cellphone" value="#cellphone#" placeholder="ex. 99900"><br />
My Interest
<select class="interestOption" name="Formprocedure" id="procedure" required >
<option selected="selected" disabled="disabled" value="">My Interest</option>
<cfloop query="procedurefinder"><option <cfif procedureid eq Formprocedure>selected="selected" </cfif>title="#procedurename#" value="#procedureid#">#left(procedurename,20)#</option>
</cfloop>
</select><br />
<textarea name="comments" cols="50" rows="5" placeholder="Please enter any additional comments"></textarea><br />
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=6LdUMuISAAAAA********mMK5cbR1pm1AG4WV">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LdUMuISAAAAAMi**************mMK5cbR1pm1AG4WV"
height="50" width="400" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="0">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
<br />
<button id="submit" onclick="SubmitForm();">Submit</button>
</cfoutput>
</form>
這是我的JS代碼:
<script type="text/javascript">
function SubmitForm(){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST",'http://www.google.com/recaptcha/api/verify',true);
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
params ="'6LdUMuISAAAAAMi4iDZ1sIuEmMK5cbR1pm1AG4WV','www.newimagespecialists.com','"+Recaptcha.get_response()+"','"+Recaptcha.get_challenge+"'";
xmlHttp.send(params);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status == 200){
form.submit();
}else{
return false;
}
}
}
}
</script>
這是我從螢火蟲得到響應:
Parameters application/x-www-form-urlencoded
'6LdUMuISAA1sIuE... =typeof RecaptchaState?null:RecaptchaState.challenge}'
Source
'6LdUMAA*******IuEmMAG4WV','www.example.com','fitsesq Accord','function(){return"undefined"==typeof RecaptchaState?null:RecaptchaState.challenge}'
我的問題是我並不真正瞭解代碼中的錯誤,以及爲什麼我的表單仍然提交?任何人都可以指出我在哪裏犯錯誤?
NOP的ReCaptcha,還是形式經歷。 – Geo
@Geo:在代碼中,我看到你手動提交表單form.submit(); 。 –
@Geo:onsubmit =「return false」僅用於在單擊時阻止提交。但是,如果您使用JavaScript提交表單,則需要檢查腳本邏輯並將其更正爲不調用form.submit() –