Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Check if a JavaScript string is a URL

function isValidURL(string) {
  var res = string.match(/(http(s)?://.)?(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
  return (res !== null)
};

var testCase1 = "http://en.wikipedia.org/wiki/Procter_&_Gamble";

alert(isValidURL(testCase1)); 
Comment

Check if a JavaScript string is a URL

function isValidURL(string) {
  var res = string.match(/(http(s)?://.)?(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
  return (res !== null)
};

var testCase1 = "http://en.wikipedia.org/wiki/Procter_&_Gamble";

alert(isValidURL(testCase1)); 
Comment

validate URL in javascript

function isValidURL(string) {
  var res = string.match(/(http(s)?://.)?(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
  return (res !== null)
};
Comment

validate URL in javascript

function isValidURL(string) {
  var res = string.match(/(http(s)?://.)?(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
  return (res !== null)
};
Comment

javascript url check

const isAbsoluteUrl = url => /^[a-z][a-z0-9+.-]*:/.test(url);

// Example
isAbsoluteUrl('https://1loc.dev');          // true
isAbsoluteUrl('https://1loc.dev/foo/bar');  // true
isAbsoluteUrl('1loc.dev');                  // false
isAbsoluteUrl('//1loc.dev'); 
Comment

javascript determine if string is valid url

function isValidHttpUrl(string) {
  let url;
  
  try {
    url = new URL(string);
  } catch (_) {
    return false;  
  }

  return url.protocol === "http:" || url.protocol === "https:";
}
Comment

javascript url check

const isAbsoluteUrl = url => /^[a-z][a-z0-9+.-]*:/.test(url);

// Example
isAbsoluteUrl('https://1loc.dev');          // true
isAbsoluteUrl('https://1loc.dev/foo/bar');  // true
isAbsoluteUrl('1loc.dev');                  // false
isAbsoluteUrl('//1loc.dev'); 
Comment

validate url javascript

validateurl
Comment

javascript determine if string is valid url

function isValidHttpUrl(string) {
  let url;
  
  try {
    url = new URL(string);
  } catch (_) {
    return false;  
  }

  return url.protocol === "http:" || url.protocol === "https:";
}
Comment

validate url in javascript

validate url
Comment

validate url javascript

validateurl
Comment

validate url in javascript

validate url
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs express use streams 
Javascript :: jquery get selected checkbox items and pass to parameter for C# MVC consumption 
Javascript :: build function component react 
Javascript :: online validator json schema 2020-12/schema 
Javascript :: react native getting old navigation parameter 
Javascript :: react native password field 
Javascript :: js check if field in database is true or false 
Javascript :: tab pane full calendar not showing 
Javascript :: jeebisah 
Javascript :: cannot Nesting classes sass nextjs 
Javascript :: index javascript array 
Javascript :: how to replace multiple characters in url in jqury 
Javascript :: IIFE module pattern in javascript 
Javascript :: closing all open files vscode 
Javascript :: alert(document.cookie); 
Javascript :: ASPxGridView - How to trigger the CustomButtonCallback event 
Javascript :: Simple Email Validation, Case Insensitive, w/ All Valid Local Part Characters (whatever tf that means to you...) - Regex 
Javascript :: "["value"]" to array js 
Javascript :: check version of 3rd package npm 
Javascript :: react computed hook 
Javascript :: Implementing cascades in mongoose 
Javascript :: jquery dropdown options in laravel 
Javascript :: Yup validation for objects and object shape 
Javascript :: typeorm sqlite Using async/await syntax 
Javascript :: react stream chat 
Javascript :: Subhasis Just search 
Javascript :: JavaScript URL Parse including pathname 
Javascript :: How to get element margin in React 
Javascript :: Async restricted or not 
Javascript :: react native red Oval bubble 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =