Попытка использовать Jquery Валидатор с Google Captcha. Но запутался, что мне использовать и как. Должен ли я использовать addMethod () или удаленную проверку файла для капчи. Мои другие проверки работают нормально, но проверка капчи не происходит. Форма просто получает подтверждение, хотя капча переименовывается.
$("#aboutquotesubmit").click(function(e){
var response = grecaptcha.getResponse();
if(response.length == 0){
e.preventDefault();
}
$("#about-quote-form").validate({
rules: {
firstname: {
required: true,
},
lastname: {
required: true,
},
phonenumber: {
required: true,
},
emailaddress: {
required: true,
email:true,
},
message: {
required: true,
}
},
errorPlacement: function() {
return false;
}
});
});
HTML CODE: -
<section class="contact_section pt-60 pb-60">
<div class="container">
<h2 class="text-info heading text-center font30 font-600">Request a Quote for Your School<span class="d-block">Semi-Custom or Fully-Custom Planners</span></h2>
<form method="post" name="about-quote-form" class="pt-20" id="about-quote-form" novalidate="novalidate" action="about_us.php">
<div class="form-row">
<div class="form-group col-md-6"><label for="firstname">First Name</label> <input class="form-control" id="firstname" name="firstname" type="text" /></div>
<div class="form-group col-md-6"><label for="lastname">Last Name</label> <input class="form-control" id="lastname" name="lastname" type="text" /></div>
</div>
<div class="form-row">
<div class="form-group col-md-6"><label for="emailaddress">Email Address</label> <input class="form-control" id="emailaddress" name="emailaddress" type="text" /></div>
<div class="form-group col-md-6"><label for="phonenumber">Phone Number</label> <input class="form-control" id="phonenumber" name="phonenumber" type="text" /></div>
</div>
<div class="form-row">
<div class="form-group col-md-12"><label for="message">Your Message</label><textarea class="form-control mw-100" id="message" name="message" rows="5"></textarea></div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<div class="g-recaptcha" data-sitekey="6LcBq94UAAAAAE8wfcw2YAkQycfdknzJSGYpn_MO"></div>
<span class="requiredInformation text-red" class="required gvalue" name="CaptchaError" id="CaptchaError"> </span>
</div>
<div class="form-group col-md-6"><input class="btn btn-primary bg-light d-block ml-auto mt-4 abel" id="aboutquotesubmit" name="aboutquotesubmit" type="submit"></div>
<p class="text-danger" id="status"> </p>
</form>
</div>
</section>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=en"></script>