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
Try this one:
^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
var re = /^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
alert(re.test(yourString));
you could use:
function checkhttpWww(s) {
var reg = /http(s?):\/\/www/;
return reg.test(s);
}
function is_correct(x) {
return /^http[s]?:\/\/www\./.test(x);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.