Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google recaptcha #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

Expand Down
10 changes: 10 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

}
5 changes: 5 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ body {
.correctCaptcha {
color: #7FFF00;
}

.google{
margin-top: 30px;
color: white;
}