输入中文域名后查询界面
要实现域名查询,首先要找到域名服务器。在这用的是万网的域名服务器。
网址为:http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=
whois:http://whois.hichina.com/cgi-bin/whois?domain=\
判断是否为中文域名(javascript):
function IsChDomain(domainStr)
{
var flag = false;
var compStr = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789";
var domainLength = domainStr.length;
for(var i = 0;i < domainLength;i++)
{
var temp = domainStr.charCodeAt(i);
if(temp >= 10000)//含有字符编码大于10000的字符判断为中文,不太严格
{
flag=true;
}
else
{
var temp2 = compStr.indexOf(domainStr.charAt(i));
if(temp2 == -1)
{
flag = false;
break;
}
}
}
return flag;
}
function IsChDomain(domainStr)
{
var flag = false;
var compStr = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789";
var domainLength = domainStr.length;
for(var i = 0;i < domainLength;i++)
{
var temp = domainStr.charCodeAt(i);
if(temp >= 10000)//含有字符编码大于10000的字符判断为中文,不太严格
{
flag=true;
}
else
{
var temp2 = compStr.indexOf(domainStr.charAt(i));
if(temp2 == -1)
{
flag = false;
break;
}
}
}
return flag;
}
输入英文域名后查询界面:
判断是否为英文域名:
function IsEnDomain(domainStr)
{
var flag = false;
var compStr = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789";
var domainLength = domainStr.length;
for(var i = 0;i<domainLength;i++)
{
if(compStr.indexOf(domainStr.charAt(i)) == -1)
{
flag = false;
break;
}
else
{
flag = true;
}
}
return flag;
}
中国等不能注册英文域名,把相应的CheckBox的disabled属性设置为true,代码为(javascript):
Code function Trim(domainStr)
{
return domainStr.replace(/(^s*)|(s*$)/g, "");
}
function checkValue()
{
if(document.getElementById("txtDomainName").value=='''')
{
alert(''请输入域名!'');
return false;
}
if(document.getElementById("txtDomainName").value.length >= 60)
{
alert(''域名长度不能超过60个字符!'');
return false;
}
for(var i = 0;i < document.getElementById("txtDomainName").value.length;i++)
{
if(document.getElementById("txtDomainName").value.charAt(i) == '' '')
{
alert(''域名中不能含有空格!'');
return false;
break;
}
}
checkDomainType();
return true;
}
function checkDomainType()
{
var domainName = document.getElementById("txtDomainName").value;
domainName = Trim(domainName);
if(IsChDomain(domainName))
{
setCheckBox(true);
}
else if(IsEnDomain(domainName))
{
setCheckBox(false);
}
}
function setCheckBox(flag)
{
document.getElementById("chkorg").disabled = flag;
document.getElementById("chkorgcn").disabled = flag;
document.getElementById("chkcomcn").disabled = flag;
document.getElementById("chknetcn").disabled = flag;
document.getElementById("chkgovcn").disabled = flag;
document.getElementById("chkmobi").disabled = flag;
document.getElementById("chkinfo").disabled = flag;
document.getElementById("chkcn").disabled = flag;
document.getElementById("chkchina").disabled = !flag;
document.getElementById("chkcompany").disabled = !flag;
document.getElementById("chknetwork").disabled = !flag;
}
|