You need to sign in to do that
Don't have an account?
Margaret Fleischaker
reCaptcha in Lightning Community web-to-case form - error adding <script>
I'm trying to use the HTML generated from the web-to-case form to add reCaptcha to a web-to-case form in a Lightning Community component. I'm running into the error that the script tag is not allowed. I'm assuming this is because it is in Lightning. Is there a simple workaround? I've seen some comments online about building a Visualforce page with the and including it in the HTML component as an iframe; is that the best approach?
<script src="https://www.google.com/recaptcha/api.js"></script> <script> function timestamp() { var response = document.getElementById("g-recaptcha-response"); if (response == null || response.value.trim() == "") {var elems = JSON.parse(document.getElementsByName("captcha_settings")[0].value);elems["ts"] = JSON.stringify(new Date().getTime());document.getElementsByName("captcha_settings")[0].value = JSON.stringify(elems); } } setInterval(timestamp, 500); </script>
All Answers
I haven't tried this in lightning, so YMMV, but I believe you could put the api.js file contents and your script method into one or more static resources, include them in your lightning component, then access the methods in lightning.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm