Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:48:51+00:00 2026-06-09T17:48:51+00:00

I’m trying to add some Input Validation in Classic ASP by using the function/code

  • 0

I’m trying to add some Input Validation in Classic ASP by using the function/code seen below.
The only one that looks like it’s working correctly is the “text” type. the others I keep getting errors or it just does not filter correctly.
I’m trying to understand what I’m doing wrong please help me.

Valid Data Types: “email”, “integer”, “date”, “string” and “text”.
The first three are obvious, the last two have slight differences.

The “email” should only allow numbers and leters, and the following characters “@” , “–” , “.” , “_“

The “date” should validate by running IsDate and if True then allow if False DON’T.

The “string” should validate text-based querystrings, allowing only letters, numbers, _, – and .

Whereas “text” is any free-form text form field type content.

The “integer” should only allow numbers and a period (.)

Usage Example: <input type="text" value="<%=MakeSafe("test@test.com</HTML>1234.5",integer,50)%>">

Eg: MakeSafe(dataInput,dataType,dataLength)

<%
'// CODE BY: dB Masters
'// FOUND AT: http://successontheweb.blogspot.com/2008/03/input-validation-for-security-in.html

Function MakeSafeConvert(encodeData)
encodeData = replace(encodeData,"&", "&#38;")
encodeData = replace(encodeData,"'", "&#39;")
encodeData = replace(encodeData,"""", "&quot;")
encodeData = replace(encodeData,">", "&gt;")
encodeData = replace(encodeData,"<", "&lt;")
encodeData = replace(encodeData,")", "&#41;")
encodeData = replace(encodeData,"(", "&#40;")
encodeData = replace(encodeData,"]", "&#93;")
encodeData = replace(encodeData,"[", "&#91;")
encodeData = replace(encodeData,"}", "&#125;")
encodeData = replace(encodeData,"{", "&#123;")
encodeData = replace(encodeData,"--", "&#45;&#45;")
encodeData = replace(encodeData,"=", "&#61;")
MakeSafeConvert = encodeData
End Function

Function MakeSafe(dataInput,dataType,dataLength)

Dim regex, validInput, expressionmatch
regex = ""
validInput = "1"

If dataType = "string" And Len(dataInput) > 0 Then
    regex = "^[\w-\.]{1,"& dataLength &"}$"
ElseIf dataType = "email" And Len(dataInput) > 0 Then
    regex = "^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$"
ElseIf dataType = "integer" And Len(dataInput) > 0 Then
    regex = "^\d{1,"& dataLength &"}$"
ElseIf dataType = "date" And Len(dataInput) > 0 Then
If Not IsDate(dataInput) Then validInput = "0" End If
ElseIf dataType = "text" And Len(dataInput) > 0 Then
If Len(dataInput) > dataLength Then validInput = "0" End If
End If

If Len(regex) > 0 And Len(dataInput) > 0 Then
    Set RegExpObj = New RegExp
    RegExpObj.Pattern = regex
    RegExpObj.IgnoreCase = True
    RegExpObj.Global = True
    RegExpChk = RegExpObj.Test(dataInput)

If Not RegExpChk Then
    validInput = "0"
    End If
    Set RegExpObj = nothing
End If

If validInput = "1" And Len(dataInput) > 0 Then
    MakeSafe = MakeSafeConvert(dataInput)
    ElseIf Len(dataInput) = 0 Then
    MakeSafe = ""
Else
    Response.Write "<h2>Processing Halted.</h2>"
    Response.End
End If

End Function
%>

EXAMPLE CODE AND ERROR(S):

When I test this using the code:

<%=MakeSafe(“test@test.com1234.5”,email,50)%>
* Does NOT Validate Anything.*



I don’t get an error message but it DOES NOT Validate anything.

**The OUTPUT IS : test@test.com1/27/20121234.5

SHOULD BE ONLY: test@test.com**

When I test this using the code:

<%=MakeSafe(“test@test.com1/27/20121234.5”,date,50)%>

I don’t get an error message but it DOES NOT Validate anything.

The OUTPUT IS : test@test.com1/27/20121234.5
SHOULD BE ONLY: 1/27/2012

The other two give me this error message:

<%=MakeSafe(“test@test.com1234.5”,string,50)%>
* ERROR!!! Wrong number of arguments or invalid property assignment: ‘string’

<%=MakeSafe(“test@test.com1234.5”,integer,50)%>

* ERROR!!! Syntax error

Thank you so much for any help that you provide…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:48:52+00:00Added an answer on June 9, 2026 at 5:48 pm

    If it’s not a typo then your fault was in the second parameter of the function call.

    You call the function like:

    <%=MakeSafe("test@test.com1234.5",email,50)%>
    

    which is wrong because you should “…” the second parameter too. This should work:

    <%=MakeSafe("test@test.com1234.5","email",50)%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.