url的正则验证
results.validator = function(value, param) {
results.message = param[0] || '';
var strRegex = ''
+ '^((https|http)://)?'
+ '('
+ '([0-9]{1,3}[.]{1}){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184
+ '|' // 允许IP和DOMAIN(域名)
+ '([0-9a-z_!~*\'()-]+[.]{1})*' // 域名- www.
+ '([0-9a-z]([0-9a-z-]{0,61}[0-9a-z])?)' // 二级域名
+ '([.]{1}[a-z]{2,6}){1,2}' // first level domain- .com or .museum
+ ')' // first level domain- .com or .museum
+ '(:[0-9]{1,4})?' // 端口- :80
+ '('
+ '(/?)|' // a slash isn't required if there is no file name
+ '((/[0-9a-z_!~*\'\(\).;\?:@&=+$,%#-]+)+/?)'
+ ')$';
var regex = new RegExp(strRegex);
return regex.test(value);
};
results.message = param[0] || '';
var strRegex = ''
+ '^((https|http)://)?'
+ '('
+ '([0-9]{1,3}[.]{1}){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184
+ '|' // 允许IP和DOMAIN(域名)
+ '([0-9a-z_!~*\'()-]+[.]{1})*' // 域名- www.
+ '([0-9a-z]([0-9a-z-]{0,61}[0-9a-z])?)' // 二级域名
+ '([.]{1}[a-z]{2,6}){1,2}' // first level domain- .com or .museum
+ ')' // first level domain- .com or .museum
+ '(:[0-9]{1,4})?' // 端口- :80
+ '('
+ '(/?)|' // a slash isn't required if there is no file name
+ '((/[0-9a-z_!~*\'\(\).;\?:@&=+$,%#-]+)+/?)'
+ ')$';
var regex = new RegExp(strRegex);
return regex.test(value);
};
请使用手机"扫一扫"x