Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating Characters for Database using RegExp in a VBScript for ASP

Status
Not open for further replies.

Shadowspawn65

Programmer
Aug 31, 2004
4
US
I am trying to validate input from a form on an ASP page that is going into an acess database. I am using asp and found some snipets of code that look like it would do what I wanted. It used vbscript and RegExp. I set up my code similar to the example only I don't get the validation back. The example seems to indicate that it will be boolean but validate is always empty, no matter what I put into the field as a test (right now I have abcde - which should be valid).

Code:
  'Fuction to check if valid data entered into fields
Function dbSafe(text)

	Response.Write("I am testing """&text&""" now <br />")
	%><script language="vbscript">
	Dim objRegEx, Validate
        Set objRegEx = New RegExp 
   	objRegEx.Pattern = "[a-zA-Z]"
	Validate = objRegEx.Test("abcde")
	</script><%
	
	If Validate then
		Response.Write("data ok")
	Else
		Response.Write("data bad")
		REsponse.Write("Validate = "&Validate)
	End If

	
End Function
 
watch out, you're about to kick yourself.

add this before End Function:
dbSafe = Validate
 
sorry, i realize now what you're asking. :(
i replaced your pattern with:
objRegEx.Pattern = "a"
and it didn't work. i'm with you...not sure what's up.
 
client vs. server mismatch

you'll need to get everything on one side of the tracks before anything will work ;)

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top