简体   繁体   中英

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

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

(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 ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM