$(document).ready(function() { // validate signup form on keyup and submit $("#submitform").validate({ rules: { Name: "required", Address: "required", Phone: "required", Email: { required: true, email: true } }, messages: { Name: "Required", Address: "Required", Phone: "Required", Email: "Enter a valid Email" } }); $("#submitform").submit(function(){ if($(this).valid()){ self.parent.$('html, body').animate( { scrollTop: self.parent.$('#myframe').offset().top }, 500 ); } if(grecaptcha.getResponse() == "") { var $recaptcha = document.querySelector('#g-recaptcha-response'); $recaptcha.setAttribute("required", "required"); $('.g-recaptcha').addClass('errors').attr('id','recaptcha'); } }); $( "input" ).keypress(function( event ) { if(grecaptcha.getResponse() == "") { var $recaptcha = document.querySelector('#g-recaptcha-response'); $recaptcha.setAttribute("required", "required"); } }); });