www.webdeveloper.com
Results 1 to 5 of 5

Thread: Validate Using Regular Expressions

  1. #1
    Join Date
    Sep 2005
    Posts
    130

    Validate Using Regular Expressions

    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:
    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

  2. #2
    Join Date
    Sep 2005
    Posts
    130
    Any suggestions.

  3. #3
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    379
    Quote Originally Posted by Jster
    Code:
    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?

    Code:
    ^[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

  4. #4
    Join Date
    Sep 2005
    Posts
    130
    Thank you that seems to work.

    Thanks,
    J

  5. #5
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    379
    You're welcome.

    Cheers

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles