showing results for - "jquery check valid link"
Emilia
19 Aug 2017
1        $.validator.addMethod("UrlVal", function (value, element) {
2
3            var Inicio_URL = ['http://www', 'https://www', 'www', 'ftp://www'];
4            var Fim_URL = ['com', 'net', 'org', 'pt', 'eu','co'];
5
6            var Url_Inserido = value.toLowerCase().split(".");
7
8            if (Inicio_URL.includes(Url_Inserido[0])) {
9
10                if (Fim_URL.includes(Url_Inserido[(Url_Inserido.length - 1)])) {
11                    return true;
12                } else
13                    return false;
14
15            } else
16                return false;
17
18        
19        })
20
Allison
26 Mar 2016
1 var myURL;
2         function validURL(myURL) {
3            var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
4            '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ // domain name
5            '((\\d{1,3}\\.){3}\\d{1,3}))'+ // ip (v4) address
6            '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ //port
7            '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
8            '(\\#[-a-z\\d_]*)?$','i');
9            return pattern.test(myURL);
10         }
11         document.write(validURL("http://qries.com"));