Code: |
[Test Captcha]
cls print "Please answer a simple math problem to continue." [Repeat Captcha] run "MathCaptcha", #captcha #captcha Difficulty(1,5) #captcha SetFocus() render #captcha button #b, "Submit", [Check Captcha] wait [Check Captcha] if #captcha IsValid() then cls print "Correct." else cls print "Incorrect. Try again." goto [Repeat Captcha] end if end |
Code: |
' Math CAPTCHA
' By Brent D. Thorn ' Created 2/2009 ' PUBLIC DOMAIN Global m.answer Global #answer Function Difficulty(low, high) low = Min(Max(low, 1), 5) high = Min(Max(high, 1), 5) n = Abs(high - low) + 1 n = Int(n * Rnd(0) + low) Select Case n Case 1 ' a + b a = Int(5 * Rnd(0) + 1) b = Int(5 * Rnd(0)) m.answer = a + b Print a;" + ";b;" = "; Case 2 ' a + b + c a = Int(10 * Rnd(0)) b = Int(10 * Rnd(0)) c = Int(10 * Rnd(0)) m.answer = a + b + c Print a;" + ";b;" + ";c;" = "; Case 3 ' aa + b a = Int(90 * Rnd(0) + 10) c = Int(10 * Rnd(0)) m.answer = a + b Print a;" + ";b;" = "; Case 4 ' a * b a = Int(10 * Rnd(0) + 1) b = Int(10 * Rnd(0) + 1) m.answer = a * b HTML a;" × ";b;" = " Case 4 ' a * b + c a = Int(10 * Rnd(0)) b = Int(10 * Rnd(0)) c = Int(10 * Rnd(0)) m.answer = a * b + c HTML a;" × ";b;" + ";c;" = " Case 5 ' a + b * c a = Int(10 * Rnd(0)) b = Int(10 * Rnd(0)) c = Int(10 * Rnd(0)) m.answer = a + b * c HTML a;" + ";b;" × ";c;" = " End Select TextBox #answer, "" End Function Function IsValid() IsValid = (#answer Value() = m.answer) End Function Function SetFocus() #answer SetFocus() End Function |