开发者

validating internet address in javascript [duplicate]

开发者 https://www.devze.com 2023-01-03 20:41 出处:网络
This question already has answers here: Closed 12 years ago. 开发者_运维百科 Possible Duplicate: how can i validate a url in javascript using regular expression
This question already has answers here: Closed 12 years ago. 开发者_运维百科

Possible Duplicate:

how can i validate a url in javascript using regular expression

I want to validate whether user input a valid internet adress like www.hotmail.com http://www.abc.com.pk


Here's the js function:

function validateString(regexPattern, testString) {
 var regexObj = new RegExp(regexPattern);
 return regexObj.test(testString);
}

Finding the regex for URLs is just a matter of typing it in google. Here's a good one I've used before.

0

精彩评论

暂无评论...
验证码 换一张
取 消