/VbScript/spamFilter.asp

http://github.com/teamaton/toolbelt · ASP · 33 lines · 32 code · 1 blank · 0 comment · 5 complexity · 797419a0a1b8986895221e536459bd29 MD5 · raw file

  1. <%@ language="VBSCRIPT" %>
  2. <%Option Explicit '*** This must be the FIRST statement ***%>
  3. <div>
  4. <%
  5. dim validChars, textNo, textYes, phoneRegex
  6. validChars = "123"
  7. textNo = "123 hallo"
  8. textYes = "(+34) 45/345-567-00.32"
  9. Function isPhoneNumber(text)
  10. dim phoneRegex, i
  11. Set phoneRegex = new regexp 'Create the RegExp object
  12. phoneRegex.Pattern = "^[\d\.\(\)/+ -]*$" ' allow only: 0123456789./()-+ and space
  13. phoneRegex.IgnoreCase = true
  14. i = 0
  15. while i < 3
  16. i = i+1
  17. wend
  18. isPhoneNumber = phoneRegex.Test(text)
  19. End Function
  20. %>
  21. <% if isPhoneNumber(textNo) then %>
  22. false
  23. <% else %>
  24. true
  25. <% End If%>
  26. <hr />
  27. <% if isPhoneNumber(textYes) then %>
  28. true
  29. <% else %>
  30. false
  31. <% End If%>
  32. </div>