javascript - custom validation not working with google recaptcha -
i have added google recaptcha in page. , javascript custom validation too. problem first time validate function gets executed after not getting executed. here code
<script src="https://www.google.com/recaptcha/api.js" async defer></script> <script language="javascript" type="text/javascript"> function submitform() { if (validateform() == true) { document.getelementbyid("form_1").submit(); } } function validateform() { if (document.getelementbyid('email').value == "") { alert(false); return false; } else { alert(true); return true; } } </script> </head> <form id="form_1" method="post" action="http://www.google.com" onsubmit="return validateform();"> <div id="divinvisiblecaptcha1" class="g-recaptcha" data-sitekey="my sitekey" data-callback="submitform" data-size="invisible" data-bind="submit_1"> </div> <table style="height:100px; width:100px"> <tr> <td>email</td> <td> <input type="text" class="ampfield" id="email" name="email" dbfieldid="email" /> </td> </tr> <tr> <td colspan="2"> <input type="button" id="submit_1" value="submit" class="g-recaptcha" data-sitekey="my sitekey" /> </td> </tr> </table>
wiki
Comments
Post a Comment