How to validate form before recaptcha runs
I am trying to implement recaptcha in one of our forms and I am using the script below. I am running into an issue where if the user does not fill out the form completely the validation kicks in but it will not let them submit the form even after correcting the info on the form. What I think is happening is the recaptcha is firing off to google server before the form is validated. How can I make sure the form is validated before it runs the recaptcha?
<script type="text/javascript">
MktoForms2.whenReady(function (form) {
jQuery( "button[type='submit']" ).addClass( "g-recaptcha" ).attr( "data-sitekey", "mykey" ).attr("data-callback","letsGo");
jQuery.getScript( "https://www.google.com/recaptcha/api.js");
letsGo = function() {
MktoForms2.whenReady(function (form) {
var v = grecaptcha.getResponse();
form.vals({"spamCheck" : v});
form.submit();
});
};
});
</script>