Magento 1.9 : Validate the Google reCaptcha in custom popup
I have added the google recaptcha in custom popup. But, form is also submitting without captcha.
I have used following codes for captcha:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
I have also used js code for validating. But, I think it's not proper way to validate it.
=> js code :
function checkcaptcha() {
if((jQuery('#g-recaptcha-response').val())=='') {
jQuery('.captcha-error').css('display','block');
return false;
} else {
jQuery('.captcha-error').css('display','none');
}
}
Please help me for validating reCaptcha in proper way.
Thanks.
Note : Do not suggest any extension link here. I want to check programmatically.
magento-1.9 captcha
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have added the google recaptcha in custom popup. But, form is also submitting without captcha.
I have used following codes for captcha:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
I have also used js code for validating. But, I think it's not proper way to validate it.
=> js code :
function checkcaptcha() {
if((jQuery('#g-recaptcha-response').val())=='') {
jQuery('.captcha-error').css('display','block');
return false;
} else {
jQuery('.captcha-error').css('display','none');
}
}
Please help me for validating reCaptcha in proper way.
Thanks.
Note : Do not suggest any extension link here. I want to check programmatically.
magento-1.9 captcha
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have added the google recaptcha in custom popup. But, form is also submitting without captcha.
I have used following codes for captcha:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
I have also used js code for validating. But, I think it's not proper way to validate it.
=> js code :
function checkcaptcha() {
if((jQuery('#g-recaptcha-response').val())=='') {
jQuery('.captcha-error').css('display','block');
return false;
} else {
jQuery('.captcha-error').css('display','none');
}
}
Please help me for validating reCaptcha in proper way.
Thanks.
Note : Do not suggest any extension link here. I want to check programmatically.
magento-1.9 captcha
I have added the google recaptcha in custom popup. But, form is also submitting without captcha.
I have used following codes for captcha:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
I have also used js code for validating. But, I think it's not proper way to validate it.
=> js code :
function checkcaptcha() {
if((jQuery('#g-recaptcha-response').val())=='') {
jQuery('.captcha-error').css('display','block');
return false;
} else {
jQuery('.captcha-error').css('display','none');
}
}
Please help me for validating reCaptcha in proper way.
Thanks.
Note : Do not suggest any extension link here. I want to check programmatically.
magento-1.9 captcha
magento-1.9 captcha
edited May 16 '18 at 5:58
Rohan Hapani
asked May 16 '18 at 5:46
Rohan HapaniRohan Hapani
1
1
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 13 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I think you have to try with using google recaptcha div class instead of id in jquery to getting google recaptcha response. I have tried below code and it's working for me:-
<div class="news-captcha">
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
</div>
JS CODE:-
var googleResponse = jQuery('.news-captcha .g-recaptcha-response').val();
if (googleResponse!= ""){
return true;
}
else {
return false;
}
After getting response you have to pass this response in input "hidden" field. In the form submit action controller function you can use this hidden field post value and check there that recaptcha response getting or empty response.
add a comment |
Please Try with below code :
<form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
<input type="button" name="submit" value="Sub" onclick="checkcaptcha();">
<div id="captcha-error"><span></span></div>
</form>
<script type="text/javascript">
function checkcaptcha() {
var googleResponse = jQuery('.g-recaptcha-response').val();
if(googleResponse !='') {
jQuery("#captcha-error span").text("Your text here");
jQuery('.captcha-error').css('display','block');
return false;
}
}
</script>
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f226169%2fmagento-1-9-validate-the-google-recaptcha-in-custom-popup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you have to try with using google recaptcha div class instead of id in jquery to getting google recaptcha response. I have tried below code and it's working for me:-
<div class="news-captcha">
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
</div>
JS CODE:-
var googleResponse = jQuery('.news-captcha .g-recaptcha-response').val();
if (googleResponse!= ""){
return true;
}
else {
return false;
}
After getting response you have to pass this response in input "hidden" field. In the form submit action controller function you can use this hidden field post value and check there that recaptcha response getting or empty response.
add a comment |
I think you have to try with using google recaptcha div class instead of id in jquery to getting google recaptcha response. I have tried below code and it's working for me:-
<div class="news-captcha">
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
</div>
JS CODE:-
var googleResponse = jQuery('.news-captcha .g-recaptcha-response').val();
if (googleResponse!= ""){
return true;
}
else {
return false;
}
After getting response you have to pass this response in input "hidden" field. In the form submit action controller function you can use this hidden field post value and check there that recaptcha response getting or empty response.
add a comment |
I think you have to try with using google recaptcha div class instead of id in jquery to getting google recaptcha response. I have tried below code and it's working for me:-
<div class="news-captcha">
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
</div>
JS CODE:-
var googleResponse = jQuery('.news-captcha .g-recaptcha-response').val();
if (googleResponse!= ""){
return true;
}
else {
return false;
}
After getting response you have to pass this response in input "hidden" field. In the form submit action controller function you can use this hidden field post value and check there that recaptcha response getting or empty response.
I think you have to try with using google recaptcha div class instead of id in jquery to getting google recaptcha response. I have tried below code and it's working for me:-
<div class="news-captcha">
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
</div>
JS CODE:-
var googleResponse = jQuery('.news-captcha .g-recaptcha-response').val();
if (googleResponse!= ""){
return true;
}
else {
return false;
}
After getting response you have to pass this response in input "hidden" field. In the form submit action controller function you can use this hidden field post value and check there that recaptcha response getting or empty response.
edited May 16 '18 at 9:43
answered May 16 '18 at 9:22
RajRaj
311112
311112
add a comment |
add a comment |
Please Try with below code :
<form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
<input type="button" name="submit" value="Sub" onclick="checkcaptcha();">
<div id="captcha-error"><span></span></div>
</form>
<script type="text/javascript">
function checkcaptcha() {
var googleResponse = jQuery('.g-recaptcha-response').val();
if(googleResponse !='') {
jQuery("#captcha-error span").text("Your text here");
jQuery('.captcha-error').css('display','block');
return false;
}
}
</script>
add a comment |
Please Try with below code :
<form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
<input type="button" name="submit" value="Sub" onclick="checkcaptcha();">
<div id="captcha-error"><span></span></div>
</form>
<script type="text/javascript">
function checkcaptcha() {
var googleResponse = jQuery('.g-recaptcha-response').val();
if(googleResponse !='') {
jQuery("#captcha-error span").text("Your text here");
jQuery('.captcha-error').css('display','block');
return false;
}
}
</script>
add a comment |
Please Try with below code :
<form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
<input type="button" name="submit" value="Sub" onclick="checkcaptcha();">
<div id="captcha-error"><span></span></div>
</form>
<script type="text/javascript">
function checkcaptcha() {
var googleResponse = jQuery('.g-recaptcha-response').val();
if(googleResponse !='') {
jQuery("#captcha-error span").text("Your text here");
jQuery('.captcha-error').css('display','block');
return false;
}
}
</script>
Please Try with below code :
<form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="XXXXXXXXXX"></div>
<input type="button" name="submit" value="Sub" onclick="checkcaptcha();">
<div id="captcha-error"><span></span></div>
</form>
<script type="text/javascript">
function checkcaptcha() {
var googleResponse = jQuery('.g-recaptcha-response').val();
if(googleResponse !='') {
jQuery("#captcha-error span").text("Your text here");
jQuery('.captcha-error').css('display','block');
return false;
}
}
</script>
answered May 16 '18 at 13:28
Ravi OzaRavi Oza
1388
1388
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f226169%2fmagento-1-9-validate-the-google-recaptcha-in-custom-popup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown