gpt4 book ai didi

javascript - 如何在view mvc razor asp.net中使用jquery真人?

转载 作者:太空宇宙 更新时间:2023-11-03 15:22:53 25 4
gpt4 key购买 nike

我在 keith-wood.name/realPerson.html 使用了 jQuery Real Person。但是,配置和测试后,它不起作用。如下是 View 中的代码片段。看起来没问题,显示验证码

enter image description here

    $('.realperson_text').realperson({
length: 6,
chars: $.realperson.alphanumeric
});
  <div class="form-group input-group-sm">
<h5>Capcha</h5>
<div class="realperson_text"></div>
@Html.TextBoxFor(p => p.defaultReal, new { @class = "form-control text-uppercase", @placeholder = "type capcha code", @maxlength = "6" })
</div>
这是 Action ,片段代码

public ActionResult UploadProfile(TestModel capcha_demo)
{
var salt = 12345;
if (rpHash(capcha_demo.defaultReal + salt) != Request.Form["realPersonHash"])
{
ViewBag.Message = "Capcha wrong";
}
}

是的,作为主页中的演示,我不知道Request.Form["realPersonH​​ash"] 是什么。你能告诉我如何获得它吗?

最佳答案

这个插件使用的技巧是在表单提交之前添加一个元素。

在插件代码 jquery.realperson.js 的第 112 行中,您有以下代码:

on('submit.' + inst.name, function() {
var name = inst.options.hashName.replace(/\{n\}/, elem.attr('name'));
var form = $(this);
form.find('input[name="' + name + '"]').remove();
form.append('<input type="hidden" class="' + self._hashClass + '" name="' + name +
'" value="' + hash(text + salt) + '">');
setTimeout(function() {
form.find('input[name="' + name + '"]').remove();
}, 0);
});

你可以看到它添加了一个输入(form.append),并且在提交之后删除了它

form.find('input[name="' + name + '"]').remove();

这就是全部!

关于javascript - 如何在view mvc razor asp.net中使用jquery真人?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36551726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com