使用javascript/jquery,验证应该包含http或https和www的URL

使用javascript/jquery,验证应该包含http或https和www的URL,javascript,jquery,Javascript,Jquery,请建议如何验证应该包含http或https和www的url 谢谢 Amit尝试使用该功能: (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") 您可以玩它试试这个: ^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w

请建议如何验证应该包含http或https和www的url

谢谢
Amit

尝试使用该功能:

(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")
您可以玩它

试试这个:

 ^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?



var re = /^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;

alert(re.test(yourString));

.

您可以使用:

function checkhttpWww(s) {
     var reg = /http(s?):\/\/www/;
      return reg.test(s);
}

抱歉,您是否尝试过?是的,我找不到一个同时检查http和WWW的脚本。此脚本在
http://www.google.co.uk/
。我真的认为你的regexp太广泛了。
function is_correct(x) {
    return /^http[s]?:\/\/www\./.test(x);
}