check if url is valid jquery code example
Example 1: jquery check if url contains string
if (window.location.href.indexOf("mystring") > -1) {
}
Example 2: jquery validator Url
$.validator.addMethod("UrlVal", function (value, element) {
var Inicio_URL = ['http://www', 'https://www', 'www', 'ftp://www'];
var Fim_URL = ['com', 'net', 'org', 'pt', 'eu','co'];
var Url_Inserido = value.toLowerCase().split(".");
if (Inicio_URL.includes(Url_Inserido[0])) {
if (Fim_URL.includes(Url_Inserido[(Url_Inserido.length - 1)])) {
return true;
} else
return false;
} else
return false;
})