ANBSCaptchaBox (Part 4)

Attempt to create Captcha inputbox as simple as possible using third party captcha.
A nice simple ASP-Pure captcha
I started to play with it, but did not finish and not tested
Originally from http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=9151

CodeFunctionName
What is this?

Public

Not Tested

Original Work
Function ANBSCaptchaBox(BCaptchaLength, BSessionVar, BName, BValue, BCaption, TextboxWidth, LabelColWidth, BLongDescription)
' Needs ANBSCaptchaGenerator.asp, RemoveHTML
' LabelColWidth = width of label = 0 to 12 (bootstrap grid width), LabelColWidth = 0 means no label
' Width of inputbox = 12 - LabelColWidth (bootstrap grid width)
' BCaptchaLength is the length of chars in captcha (no of imaages)
' BSessionVar = the name of variable to save captcha for comparison
' Has to be ANBSCaptchaImageID
' If changed, then modify it in ANBSCaptchaGenerator.asp
' Using Bootstrap 4, if LabelColWidth = 3, inputbox width = 9
' Only if TextboxWidth = 0
Rett = ""
DescDiv = ""
InputStyle = ""
Div2Close = vbcrlf
TextboxWidth = Fix(TextboxWidth)
LabelColWidth = Fix(LabelColWidth)
Dir_CaptchaGenerator = "ANBSCaptchaGenerator.asp?img="
If BLongDescription > "" Then
DescDiv = DescDiv & " <small class=""form-text text-muted"" >" & vbcrlf
DescDiv = DescDiv & BLongDescription & vbcrlf
DescDiv = DescDiv & " </small >" & vbcrlf
End If
Dim RndNum', ImageNo
Randomize Timer
' ImageNo = CStr(Fix(99999 * Rnd)) 'Here you can set the max number of images to be shown, ie. 99999999
' Session("ImageNo") = ImageNo 'Session variable of the final number to be shown
Session(BSessionVar) = BCaptchaLength 'Session variable of the final number to be shown
For i = 1 To Len(BCaptchaLength)
RndNum = 99999 * Rnd 'Random number to avoid caching
' here, 'img' shows which number should be displayed, we write the image tag
' to get the image from asp page.
Rett = Rett & ""
Rett = Rett & " <img src=""" & Dir_CaptchaGenerator & i & "&rnd=" & RndNum & """ / >"
Next

If LabelColWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelColWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelColWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
If TextboxWidth > 0 Then InputStyle = " Style=""width:" & TextboxWidth & "px"" "
Rett = Rett & " <input type=""text"" id=""" & BName & """ name=""" & BName & """ "
Rett = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
ANBSCaptchaBox = Rett & "value=""" & BValue & """ " & InputStyle & " >" & DescDiv & Div2Close
End Function

BCaptchaLength, BSessionVar, BName, BValue, BCaption, TextboxWidth, LabelColWidth, BLongDescription

Views 1,533

Downloads 675

CodeID
DB ID