Click to See Complete Forum and Search --> : Validate Using Regular Expressions


Jster
03-07-2006, 10:17 AM
I'm having a difficult time in finding or making my own user validating Regular Expression. The format for our User name is something like BOB.12345. If I use the RegExp "[^a-zA-Z0-9\.]", and I put in ' or 1=1-- in the text field, it displays or 1=1--. It didn't even strip out the = or the --.

Here is the code:

Function Sanitize(strInput)
Set regExLogin = new RegExp
regExLogin.Pattern = "[^a-zA-Z0-9\.]"
Sanitize = regExLogin.Replace(strInput,"")
End Function


Any help would be appreciated.

Thanks,
Jster

Jster
03-08-2006, 09:23 AM
Any suggestions.

JayM
03-08-2006, 12:01 PM
Function Sanitize(strInput)
Set regExLogin = new RegExp
regExLogin.Pattern = "[^a-zA-Z0-9\.]"
Sanitize = regExLogin.Replace(strInput,"")
End Function



My knowledge in Regular Expressions is not so good since I've only used them on a few occasions, but I believe your pattern is incorrect format. Shouldn't it be something like this?


^[a-z]|[A-Z]\.[0-9]


Give it a try and see if it works. Meanwhile, I'll look more into this and see if I can find an answer.

Regards

Jster
03-08-2006, 01:28 PM
Thank you that seems to work.

Thanks,
J

JayM
03-08-2006, 01:40 PM
You're welcome. :)

Cheers