dav*_*orp 12 javascript forms captcha http recaptcha
是否可以自定义reCAPTCHA表单参数(recaptcha_challenge_field和recaptcha_response_field)以便以不同方式调用它们?
基本上我希望将表单参数recaptcha_challenge_field称为captchaId,将recaptcha_response_field称为captchaUserResponse.
我希望它们重命名,以便我可以抽象验证码实现 ...当请求到达时
POST/mysite/userSignup
我不想打扰验证码实现(reCaptcha,或将来的其他东西) - 为正确的验证码实现提取正确的参数,我想统一这些参数名称.
现在我的请求看起来像这样:
POST /mysite/userSignup HTTP/1.1
Host: localhost:80
Connection: keep-alive
Content-Length: 416
Cache-Control: max-age=0
Origin: http://localhost:80
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://localhost:8080/mysite/signup/form.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,hr;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
email:testUser%40gmail.com
username:testUser
password:test
password2:test
forename:Test
surname:User
recaptcha_challenge_field:<google generated challange>
recaptcha_response_field:<user typed captcha answer>
submit:Submit
Run Code Online (Sandbox Code Playgroud)
但我希望它看起来像这样:
POST /mysite/userSignup HTTP/1.1
Host: localhost:80
Connection: keep-alive
Content-Length: 416
Cache-Control: max-age=0
Origin: http://localhost:80
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://localhost:8080/mysite/signup/form.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,hr;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
email:testUser%40gmail.com
username:testUser
password:test
password2:test
forename:Test
surname:User
captchaId:<google generated challange>
captchaUserResponse:<user typed captcha answer>
submit:Submit
Run Code Online (Sandbox Code Playgroud)
一种优雅的方式是指定那些表单参数名称,如下所示:
<script>
var RecaptchaOptions = {
recaptcha_challenge_field_formparam_name : 'captchaId',
recaptcha_response_field_formparam_name: 'captchaUserResponse'
};
</script>
Run Code Online (Sandbox Code Playgroud)
如果无法做到这一点,您建议使用哪种解决方法?
这应该是不可能的。可能的解决方案 AFAIU 是添加新的 DOM 元素,这些元素在表单提交之前复制原始元素的值,例如:
<!-- the HTML part -->
<input type="hidden" id="captchaId">
<input type="hidden" id="captchaUserResponse">
// the JavaScript (jQuery) part
$('form').submit(function(){
$('input#captchaId').
val($('input#recaptcha_response_field').val());
$('input#captchaUserResponse').
val($('input#recaptcha_challenge_field').val());
return true;
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5579 次 |
最近记录: |