简体   繁体   中英

How to use jquery real person in view mvc razor asp.net?

i have use jQuery Real Person at keith-wood.name/realPerson.html . However, after config and test, It's not work.As follow is snippet code in view.Look so it's ok, show capcha

在此处输入图片说明

  $('.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> 
And this is action, snippet code

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

Yep, as demo in home page, I don't known what is the Request.Form["realPersonHash"] . Can you tell me how to get it ?

The trick this plugin use it's to add an element before form submit.

In plugin code jquery.realperson.js line 112 you have this code:

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);
            });

You can see that it add an input (form.append), and delete it just after the submit

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

That's all the trick!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM