开发者

validating internet address in javascript [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜