Url Validate Script

URL is a uniform resource locator.In this Url Validate Script is used to validate all type of url address like check this separate www,domain,.com.

Demo :



Enter URL :  

Example :

http://www.tutorialsscripts.com/ts/free-java-scripts/url-validation.php

Code :

If you need validate url address code for your website following code helpful to you.


function isURL(argvalue)
{
  if (argvalue.indexOf(" ") != -1)
     return false;
  else if (argvalue.indexOf("http://") == -1)
    return false;
  else if (argvalue == "http://")
    return false;
  else if (argvalue.indexOf("http://") > 0)
    return false;

  argvalue = argvalue.substring(7, argvalue.length);
  if (argvalue.indexOf(".") == -1)
    return false;
   else if (argvalue.indexOf(".") == 0)
    return false;
   else if (argvalue.charAt(argvalue.length - 1) == ".")
    return false;

  if (argvalue.indexOf("/") != -1) {
    argvalue = argvalue.substring(0, argvalue.indexOf("/"));
  if (argvalue.charAt(argvalue.length - 1) == ".")
  return false;
}
  if (argvalue.indexOf(":") != -1) {
    if (argvalue.indexOf(":") == (argvalue.length - 1))
    return false;
  else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
    return false;
  argvalue = argvalue.substring(0, argvalue.indexOf(":"));
  if (argvalue.charAt(argvalue.length - 1) == ".")
   return false;
}
  return true;
}

In the above java script function is used to validate for url. This function is called with one argument that name is argvalue.When you click submit button in the form url will pass to isURL function .if the url is correct isURL function will return 'This is valid Url' alert otherwise will return 'This is Invalid Url' alert.

Free Download Script:

If you need to url validate script click and download from following zip file.

Download -->




Content