Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

url validator javascript

function validURL(str) {
  var pattern = new RegExp('^(https?://)?'+ // protocol
    '((([a-zd]([a-zd-]*[a-zd])*).)+[a-z]{2,}|'+ // domain name
    '((d{1,3}.){3}d{1,3}))'+ // OR ip (v4) address
    '(:d+)?(/[-a-zd%_.~+]*)*'+ // port and path
    '(?[;&a-zd%_.~+=-]*)?'+ // query string
    '(#[-a-zd_]*)?$','i'); // fragment locator
  return !!pattern.test(str);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #url #validator #javascript
ADD COMMENT
Topic
Name
2+2 =