diff --git a/index.html b/index.html index 5333b24..d4d09f5 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,9 @@ <head> <link rel="stylesheet" type="text/css" href="styles.css"> + <!-- Google Recaptcha API--> + <script src="https://www.google.com/recaptcha/api.js" async defer></script> + </head> <body> @@ -12,12 +15,26 @@ <h1 id="captchaHeading">Captcha Validator Using HTML, CSS and JavaScript</h1> <canvas id="captcha">captcha text</canvas> <input id="textBox" type="text" name="text"> <div id="buttons"> + <input id="submitButton" type="submit"> <button id="refreshButton" type="submit">Refresh</button> </div> + + <span id="output"></span> </div> </div> +<!-- Google Recaptcha--> + <div class="center google"> + <h1>Google Recaptcha v2</h1> + <form onsubmit="getResponse()" > + <div class="g-recaptcha" id="widgetId1" data-sitekey="6Ld_Zx0pAAAAAIFeSlojRE4W3wUqioyfyS8f2aUJ"></div> + <br/> + <input type="submit" id="googleBtn" value="Submit"> + + </form> + </div> + <script src="script.js"></script> </body> diff --git a/script.js b/script.js index 1824dca..75fcabf 100644 --- a/script.js +++ b/script.js @@ -74,3 +74,13 @@ refreshButton.addEventListener('click', function() { ctx.fillText(refreshArr.join(''),captchaText.width/4, captchaText.height/2); output.innerHTML = ""; }); + +// Google Recaptcha Alert +let getResponse = (e)=>{ + if(grecaptcha.getResponse() != ""){ + alert("Correct") + document.querySelector("#outputgoogle").innerHTML = "Coorect" + + } + +} diff --git a/styles.css b/styles.css index 5be9551..c7245d5 100644 --- a/styles.css +++ b/styles.css @@ -59,3 +59,8 @@ body { .correctCaptcha { color: #7FFF00; } + +.google{ + margin-top: 30px; + color: white; +} \ No newline at end of file