Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

URL Validation


If you want to validate an URL in input fields, here is the JS code:

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

Comments are closed.

%d bloggers like this: