[英]Using javascript/jquery, validate URL that should have http or https and www
请建议如何验证应该有 http 或 https 和 www 的 url
谢谢阿米特
尝试使用该 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")
你可以在这里玩
试试这个:
^(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);
}
function is_correct(x) {
return /^http[s]?:\/\/www\./.test(x);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.