Please advice how to validate a url that should have http or https and www in it
Thanks Amit
Please advice how to validate a url that should have http or https and www in it
Thanks Amit
Try to use that function:
(function isURL(s) {
var regexp = /http(s?):\/\/www\.[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
return regexp.test(s);
})("https://www.google.com")
you may play with it here
http://www.google.co.uk/. I honestly think your regexp is too extensive.Try this one:
^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
var re = /^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
alert(re.test(yourString));