SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    web url checking

    expression:

    Code:
    var expression = /^[a-zA-Z0-9\-\.\/]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/;
    
    Above expression is failing the urls where we have path available after .edu. How can i fix the expression that it supports these urls also?

    secure.loyno.edu/apply/application

    Also, am i limiting the user by specifying certain tlds? Should i change this too?

    Thanks
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    changed the expression to following and it is checking what i am looking for (hopefully i am not overlooking some thing):
    var expression = new RegExp("^([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");

    Per:
    http://stackoverflow.com/questions/1...ing-javascript
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm sure if someone tried, they could make it fail. But yes, that looks a bit more serious. I think there are so many possible variations that it's almost not worth it. You might as well just check there is a dot in it and that's it.

  4. #4
    Web Developer stickycarrots's Avatar
    Join Date
    Jul 2005
    Location
    Illinois State University
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    I'm sure if someone tried, they could make it fail. But yes, that looks a bit more serious. I think there are so many possible variations that it's almost not worth it. You might as well just check there is a dot in it and that's it.
    haha, I agree. I've had a similar situation in the past when checking the URL and just decided to put a note of what I am expecting from the user and did a general check.


Bookmarks

Posting Permissions

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