I was trying to implement reCaptcha on a form, but when I finally got the captcha to work, my form stopped checking that the fields with required attribute are populated.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<meta charset="UTF-8">
<meta name="description" content="Site da Contabilidade Guarucontas">
<meta name="keywords" content="Guarucontas, Contabilidade, Lauro, Empresas">
<meta name="author" content="Pedro Botolli">
<title>Guarucontas Serviços para Empresas Ltda.</title>
<script src="https://www.google.com/recaptcha/api.js"asyncdefer></script><script>functiononSubmit(token){document.getElementById("i-recaptcha").submit();
}
</script>
</head>
<body>
<?php
if(isset($_POST['g-recaptcha-response'])) {
$secretKey = '-----minhasecretkey----';
$response = $_POST['g-recaptcha-response'];
$remoteIp = $_SERVER['REMOTE_ADDR'];
$reCaptchaValidationUrl = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$response&remoteip=$remoteIp");
$result = json_decode($reCaptchaValidationUrl, TRUE);
//get response along side with all results
//print_r($result);
if($result['success'] == 1): ?>
<div>Tudo certo, o formulario foi enviado!</div>
<?php else: ?>
<div>Erro, tente novamente...</div>
<?php
endif;
}
?>
<form action="/index.php" method="post" id="i-recaptcha">
<label>Entrada:</label>
<input type="text" name="entrada" required/>
<br>
<button type="submit" class="g-recaptcha" data-sitekey="------minhasitekey------" data-callback="onSubmit">
Enviar
</button>
</form>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
</html>