View Full Version : Help needed about Javascript URL validation
computerzworld
Oct 5th 2007, 12:52 am
Hi friends. I am making URL validation with Javascript. The format I need for the URL is http://example.com without considering www in the URL. Please help me. Thanks in adavance.
try this one
function checkURL(value) {
var myregex = new RegExp("^(http:\/\/|https:\/\/|ftp:\/\/){1}([0-9A-Za-z]+\.)");
if(myregex.test(value)) {
return(true);
}
else {
return(false);
}
computerzworld
Oct 5th 2007, 7:47 pm
thnaks for the help..... i have tried like this...
function checkURL()
{
var url = document.frm1.url.value;
var myregex =new RegExp("^(http:\/\/){1}([0-9A-Za-z]+\.)");
if(myregex.test(url))
{
document.write(url);
return true;
}
else
{
alert("Error");
return false;
}
}
but it is considering www in the validation and i need url without www. So how to ignore www using this? plz help me... Thanks again.....
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.