October 20, 2020 at 12:05 am
#10034802
Keymaster
Hello,
The advanced contact form (contact-us-advanced.php) is not ready for use with recaptcha v3. This case we need remove the validation of fields at front end and make it on server side (PHP).
1) First remove the view.contact.js script from the page:
<script src="js/views/view.contact.js"></script>
2) Change the recaptcha script on footer with this new code:
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
function onSubmit(token) {
document.getElementById("contactFormAdvanced").submit();
}
</script>
3) Inside the from, change the submit button from this:
<input type="submit" value="Submit Now" class="btn btn-outline custom-btn-style-4 text-uppercase mt-1" data-loading-text="Sending...">
To this:
<input type="submit" value="Submit Now" class="btn btn-primary btn-modern pull-right g-recaptcha" data-sitekey="YOUR_V3_SITE_KEY" data-callback='onSubmit' data-action='submit' data-loading-text="Sending...">
4) Now we need make the validation of fields on server side. First change the HTML of fields to this new:
https://pastebin.com/raw/fC6XLL0b
On top of page at the PHP code, change this:
if(isset($_POST['emailSent'])) {
To this:
if( isset($_POST['emailSent']) && !empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['message']) ) {
Please try that and let us know if you need further assistance.
Kind Regards,
Rodrigo.