jimfog Posted July 3, 2013 Share Posted July 3, 2013 I have come across in the web with various code examples regarding url validation. Nonetheless I want to hear from you also what code might work here-based on your experience. Obviously we are talking here about a Regular Expression. Link to comment Share on other sites More sharing options...
Ingolme Posted July 3, 2013 Share Posted July 3, 2013 I haven't encountered a situation where a URL has to be verified. You just need to make sure they aren't allowed to start the URL with "javascript:" so the user can't mess up your site. You probably only need to check that the URL starts with http: // or https: // but you could use an expression that generalizes for any protocol (excluding "javascript:") Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2013 Share Posted July 3, 2013 I'm not sure I would validate a URL in Javascript. In PHP I would use filter_var with the URL filter, and parse_url. I would use parse_url to break it up and then rebuild it myself so that it only contains the parts I want, if I don't want everything. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now