开发者

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

开发者 https://www.devze.com 2023-03-03 16:16 出处:网络
in javascript I get a string that should be something like: 开发者_Go百科website.tld/something www.website.tld/something

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

精彩评论

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