I want to validate urls. It should accept:
http://google.com http://www.google.com www.google.com google.com
I refer Regex to match URL
Simply prepend http:// if it's not there and then test.
http://
if (inputURL.substring(0,7) != 'http://' && inputURL.substring(0,8) != 'https://') { inputURL = 'http://' + inputURL; }
No large libraries required or anything, just a few lines of code.