Sharpharp1
Apprentice

Preventing spam in forms - ReCaptcha?

Hi,

 

I'm interested in using a ReCaptcha type element to a form in order to prevent spam, has anyone here managed to encorporate this type of security steps in a k2 Form? i.e. ReCaptcha, Solve a maths question, identify an item for example?

 

I'm on v4.7 blackpearl, so would appreciate any help in how this can be used in a form and how the process would work?

 

Thanks

0 Kudos
Reply
7 Replies
Sharpharp1
Apprentice

Re: Preventing spam in forms - ReCaptcha?

Just bumping this thread.

 

Any ideas?

0 Kudos
Reply
tin
Apprentice

Re: Preventing spam in forms - ReCaptcha?

It looks like you may be able to add this reCaptcha functionality to a SmarForms:


* requires a Google Account 


 


https://www.a2hosting.com/blog/implement-captcha-solution-website/


 


Step #1: Register Your Website on reCAPTCHA 


5178iC61510361613928A.png


 


*  looks like you just need a Label and the applicable domain


5180iA667E38216257D36.png


 


Add a literal [data label1] with expression and the recaptcha script:


5181iAD4B0F3B50243EF9.png


 


On another literal [data label2], add the div that would have the captcha


5182iD9F461B5F7054899.png


 


 


The same information is avalable at:


5183iF331373161022B27.png


 


 


I am not yet sure of to validate via server side, but from client side I used the information from:


https://stackoverflow.com/questions/27902539/how-can-i-validate-google-recaptcha-v2-using-javascript...


http://community.k2.com/t5/K2-blackpearl/SmartForms-How-to-execute-JavaScript-via-rules/ta-p/90846


 


Adding another literal [data label3] and mapping this to the button click event that would submit stuff:


5184i1F0B5300CE965A68.png


 


As per the kb article above, the first data transfer just transfers an blank value to clear, and the second would would transfer the client side check:


5185iE2582E48BF55E072.png


 


If I submit without the captcha completed:


5186i68155A05A80F6148.png


 


Captcha:


5187i6E2AB5AC4FDF6F6A.png


 


If I submit with captcha filled out:


5188i9C04320751EB8EFC.png


 


Perhaps instead of alert, a value can be set on another data label (hidden) and then a condition can be used to check this before submitting or not submitting.

Reply
Albarghouthy
Apprentice

Re: Preventing spam in forms - ReCaptcha?

Hi Sharpharp1,


 


Adding to 


 


 



 




 


 


 



<script type="text/javascript">
var correctCaptcha = function(response) {
$("[name='dlResponse']").SFCLabel('option', 'text', 'Good');
};
</script>


 


data-callback="correctCaptcha">


 


Reply
Sharpharp1
Apprentice

Re: Preventing spam in forms - ReCaptcha?

Hi all,

 

Thanks for the replies.

 

@tin - I set your solution up, can i ask if you could post a screen grab of that first transfer action.

 

I can get the recaptcha to appear, but when clicking on a square, it fades out white and the recaptcha loads a different pic. I ended up refreshing and the same happens. Eventually the ticked squared stayed, but more often than not it's just fading and loading a new box....

 

@mustafa - How is your solution different? Can you do a step by step? - Are you adding two extra data labels to tins solution, or is this a different way altogether?

0 Kudos
Reply
Albarghouthy
Apprentice

Re: Preventing spam in forms - ReCaptcha?

Hi Sharpharp1,


 


This is how its designed, there are 2 different versions or reCAPTCHA, one that you can select multiple images at a time and the other one for example when it asks you to select images that has car or road, this will require more than one image to be selecte and when you select one image it will be submited and the grid will refresh or show another image until all the required images are selected then you can verify it.


 


my solution is the same as tin's soluton, the only difference is when you verify the reCAPTCHA, the response will be transferred to a data label without clicking a button, just skipping the button click to validate the response.


 


 

0 Kudos
Reply
Sharpharp1
Apprentice

Re: Preventing spam in forms - ReCaptcha?

Thanks for the explanation Mustafa,

 

I got both versions working, thanks to both you and Tin for the help, i'm sure this will come in useful for others as well.

 

I've used your auto response combined with a "if the data label is changed" rule to then move onto processing the next stages such as workflows etc.

 

Nice one !!!

 

 

0 Kudos
Reply
SrinivasK
Scholar

Re: Preventing spam in forms - ReCaptcha?

Hi,

 

I followed the instructions till adding the datalable-2(On another literal [data label2], add the div that would have the captcha) and run the view, but captcha is not displaying, view is total blank(refer screenshot-5).

Note: Java script is enabled in my browser.

Screenshot1:

 7733i35DBAB94A04BEDA5.png

 

Do i need to make any other changes?

 

Regrads

SK

 

 

0 Kudos
Reply