Jquery表单与recaptcha序列化问题?
尝试使用表单中的验证码序列化表单。
以下是我序列化表单的方式:
var serializedform = $('form.af').serialize();
这是我的表单示例:
<form class = 'af'>
<input name='name' id = 'name'>
<input name='lastname' id = 'lastname'>
<div id = 'recaptchadiv'>
<input name='recaptcha_response_field' id = 'recaptcha_response_field'>
<input name='recaptcha_challenge_field' id = 'recaptcha_challenge_field'>
<noscript>
<input name='recaptcha_response_field' id = 'recaptcha_response_field'>
<input name='recaptcha_challenge_field' id = 'recaptcha_challenge_field'>
</noscript>
</div>
<button name = 'submit'>
</form>
问题来自 recaptcha 自动注入的 recaptcha noscript 块。 该块包含 recaptcha_response_field 和 recaptcha_challenge_field 的副本。
因此,当我序列化此表单时,noscript 块输入中的值会覆盖真实的 recaptcha_response_field 和 recaptcha_challenge_field 值。
有没有办法使用 jquery 序列化表单,同时跳过 noscript 块?
谢谢:)
Trying to serialize a form with recaptcha in the form.
Here is how I serialize my form:
var serializedform = $('form.af').serialize();
Here is my form example:
<form class = 'af'>
<input name='name' id = 'name'>
<input name='lastname' id = 'lastname'>
<div id = 'recaptchadiv'>
<input name='recaptcha_response_field' id = 'recaptcha_response_field'>
<input name='recaptcha_challenge_field' id = 'recaptcha_challenge_field'>
<noscript>
<input name='recaptcha_response_field' id = 'recaptcha_response_field'>
<input name='recaptcha_challenge_field' id = 'recaptcha_challenge_field'>
</noscript>
</div>
<button name = 'submit'>
</form>
problem comes from recaptcha noscript block injected by recaptcha automatically.
That block contains a copy of recaptcha_response_field and recaptcha_challenge_field.
So - when I serialize this form - values from noscript block inputs overwrite real recaptcha_response_field and recaptcha_challenge_field values.
Is there a way to serialize a form using jquery while skipping noscript block?
Thanks:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在表单之前使用 jQuery 删除
标签序列化 - 显然,到那时它们就没有必要了。像这样的东西:
You could use jQuery to remove the
<noscript>
tags before the form is serialized - clearly, they aren't necessary by that point. Something like this:noscript 标签的内容甚至不应该出现在 DOM 中,因此不需要删除它们。请参阅演示。
您确定 noscript 标签的内容已序列化吗?
The contents of the noscript tags shouldn't even be present in the DOM in the first place so there should be no need to remove them. See DEMO.
Are you sure that the contents of your noscript tags get serialized?