good day

The problem is that if the script with the callback function for reCaptcha is in the same html where this reCaptcha is inserted, then the callback is triggered, and when the script is moved to an external file, it is not (the other functions of the script are performed as necessary)

#feedback.html.haml ... .row = recaptcha_tags :callback => "re_check" ... #script.js $(function(){ ... function re_check(){ if ((name_f.value == "")|| (phone_f.value == "")){ show_error(); } validate(); } ... }) 

How to fix?


Posted on September 1

The problem was not that the script is in an external file, but that it is wrapped in $ (function () {}). Not yet figured out how to fix

  • Well, then the question is how do you connect this external file. Try inserting such a function into a callback function () {alert (re_check); } and define it in the same file. - vihtor
  • @vihtor, = recaptcha_tags: callback => "function () {alert (re_check);}", right? If so, it did not help - Kakao Developer
  • I am not strong in haml, but I need to do it like this <recaptcha_tags callback = "alert (re_check)"> - vihtor
  • What errors appeared in the console after the function was moved to a separate file? - Fomina Catherine
  • @vihtor, then the code looks like this:: callback => "alert (re_check)", did not help. - Kakao Developer

0