Thursday, 16 February 2017

JavaScript: Regular expression to validate URL


Please find below JavaScript code to validate URL using regex expression.

function ValidURL(url) {
 var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;        return regexp.test(url);
}

No comments:

Post a Comment