Wednesday 2 November 2011

Text Captcha with InfoPath form in SharePoint 2010

For past few days I have been searching blogs/forums to find a way to use Text Captcha with InfoPath form, but in vain. I have a created a simple Text Captcha functionality in InfoPath form and penning it down here, so that somebody outside there will face less pain than me.  

To start with, create a new InfoPath form in InfoPath Designer 2010. Change the color of the Text Box and make it Read-only, which will hold the Captcha text. We call it “Security Check” Text Box.




In Text Box Properties of “Security Check”, set the Default Value as the below formula.




This formula will generate a new number each time the page is loaded --
substring(string(number(concat(number(substring(substring-after(string(now()), "T"), 7, 2)) * 3 + 31, number(substring(substring-after(string(now()), "T"), 7, 2)) * 5 + 17, number(substring(substring-after(string(now()), "T"), 7, 2)) * 9 + 37))), 2, 5)

Now go to “Manage Rule” for “Enter the numbers shown” Text Box, as shown below.


In Rules window, click on Condition and add the below condition. The condition states that Captcha-Text should not be equal to Entered-Text. Click “OK” and enter "ScreenTip" in Rules window on right side.



Now publish the page and see the result. It will display a page with a Text-Captcha.


On entering incorrect value, it display screen tip and will not proceed further.



On entering correct value, the data is submitted.


==========================================



2 comments:

  1. hi Neeraj, thanks for sharing info. this CAPACH use cleare text any hacking application can read these images. do you know any way to add complex image to infopath form??

    ReplyDelete
  2. Great post Neeraj, what is your new?

    Hi Emma, check this project http://distinctcaptcha.codeplex.com/

    ReplyDelete