开发者

ReCaptcha: hooking to TextBox's OnKeyDown from script

I'm working with ReCaptcha, ASP.NET and Gaia Ajax. It took me some time to use the ReCaptcha AJAX APIs combined with Gaia to retrieve the contents of the recaptcha_response_field text box in AJAX postback throug开发者_StackOverflow中文版h a patch.

This was just to introduce you to the subject. Now I would like to apply another patch to ReCaptcha, without reimplementing it (a comprehensive open source library that works better than current ASP.NET implementation would be desirable, but I have no time for that): this question explains which.

Basically,

I need, after calling ReCaptcha.Create(), which renders the CAPTCHA during an AJAX postback, to hook to the OnKeyDown event of recaptcha_response_field and inject my Javascript snippet that prevents the form from being submitted.

You understand that since I don't render the <input> tag (I don't have control over it), I must hook from the external.

In general,

I think you may actually answer the general question: "how to set JavaScript event handlers programmatically?" because this surely applies to all classes of events.

Thank you


I wouldn't recommend on-the-fly checking of captcha, because then a program could just brute force it, after figuring out the basic characters of the picture.

I always use jquery for event handlers something like:

  $(function() 
  {
    $("#{TEXTBOXID}").keydown(function(event)
    {
      alert(event.keyCode);
    });
  });

(taken from Why does JQuery keydown work for window but not textbox?)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜