function validateDNS() {

//-- domain name must be at least two characters in length.

   if (document.domainform.domainname.value.length < 2) {
      window.alert("Domain name must be at least three characters!");
      document.domainform.domainname.select();
      return false;
   }

//-- domain name must consist on only letters, numbers and hyphens

   userDomainName = document.domainform.domainname.value.toLowerCase();  
   var validChars = "abcdefghijklmnopqrstuvwxyz0123456789-";
   for (var index = 0; index < userDomainName.length; index++) {
      if (validChars.indexOf(userDomainName.charAt(index)) == -1) {
         window.alert("Domain name can only contain letters, numbers and hyphens!");
         document.domainform.domainname.select();
         return false;
      }
   }

//-- Hyphens cannot be at the start or end of the name.

   if (userDomainName.substring(0,1) == "-") {
      window.alert("Domain name cannot start with a hyphen!");
      document.domainform.domainname.select();
      return false;
   }
   if (userDomainName.substring(userDomainName.length - 1,userDomainName.length) == "-") {
      window.alert("Domain name cannot end with a hyphen!");
      document.domainform.domainname.select();
      return false;
   }

//-- domain name cannot contain double hyphens.

   var validChars = "-";
   for (var index = 0; index < userDomainName.length - 1; index++) {
      if (validChars.indexOf(userDomainName.charAt(index)) != -1 & validChars.indexOf(userDomainName.charAt(index+1)) != -1) {
         window.alert("Domain name cannot contain double hyphens!");
         document.domainform.domainname.select();
         return false;
      }
   }

//-- domain name format is good

   document.domainform.domainname.value = userDomainName;
   document.getElementById("wait").firstChild.nodeValue = "Searching, please wait.......";
   return true;   
}
