开发者

Validate and add http and/or www to string using javascript

in javascript I get a string that should be something like:

  • 开发者_Go百科website.tld/something
  • www.website.tld/something
  • http://www.website.tld/something

(also third level and lower domains)

I need that 1st the string is validate, 2nd if the string isn't in the third case (http://www.website.tld/something), it has to concat "http://" and/or "www".

Anyone has some tip or knows where to find a ready-to-use script that implement this?


If you use jQuery (or can use it), I recommend the excellent validator plugin which has a built-in function which validates jQuery Validate

It's easy to use, and works well

DISCLAIMER: I am not involved in this project nor knowing the creator. Just a simple satisfied user ;-)


I would use a regular expression to match to see what action you should take.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜